From d6d6c3343cd023e9f87ce1236db957b04549065b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:58:51 +0800 Subject: [PATCH 1/4] choosenim supports macos arm64 nightlies --- src/choosenimpkg/utils.nim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/choosenimpkg/utils.nim b/src/choosenimpkg/utils.nim index b7ef63b..911c935 100644 --- a/src/choosenimpkg/utils.nim +++ b/src/choosenimpkg/utils.nim @@ -198,10 +198,7 @@ proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) = if "x" & $arch in aname: result = (url, tagName) else: - # when choosenim become arm64 binary, isRosetta will be false. But we don't have nightlies for arm64 yet. - # So, we should check if choosenim is compiled as x86_64 (nim's system.hostCPU returns amd64 even on Apple Silicon machines) - if not isRosetta() and hostCPU == "amd64": - result = (url, tagName) + result = (url, tagName) if result[0].len != 0: break if result[0].len != 0: From 73be773dc8f78286e8c1e65855af79213ccee394 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:26:12 +0800 Subject: [PATCH 2/4] fixes macOS 13 --- src/choosenimpkg/utils.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/choosenimpkg/utils.nim b/src/choosenimpkg/utils.nim index 911c935..9280c4c 100644 --- a/src/choosenimpkg/utils.nim +++ b/src/choosenimpkg/utils.nim @@ -198,7 +198,8 @@ proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) = if "x" & $arch in aname: result = (url, tagName) else: - result = (url, tagName) + if $hostCPU in aname: + result = (url, tagName) if result[0].len != 0: break if result[0].len != 0: From 4b1d6eef5d8a447fc18f7d15c13cbc12875b3398 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:26:25 +0800 Subject: [PATCH 3/4] bump to 0.8.12 --- choosenim.nimble | 2 +- src/choosenimpkg/common.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/choosenim.nimble b/choosenim.nimble index f8c0127..e085c20 100644 --- a/choosenim.nimble +++ b/choosenim.nimble @@ -1,6 +1,6 @@ # Package -version = "0.8.10" +version = "0.8.12" author = "Dominik Picheta" description = "The Nim toolchain installer." license = "BSD" diff --git a/src/choosenimpkg/common.nim b/src/choosenimpkg/common.nim index 2d29c9d..c550c13 100644 --- a/src/choosenimpkg/common.nim +++ b/src/choosenimpkg/common.nim @@ -4,7 +4,7 @@ type ChooseNimError* = object of NimbleError const - chooseNimVersion* = "0.8.10" + chooseNimVersion* = "0.8.12" proxies* = [ "nim", From 3170e0d47cd0ed5b2a51c69e9778fbddd6a80d9b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:55:56 +0800 Subject: [PATCH 4/4] fixes --- src/choosenimpkg/download.nim | 31 ++++++++++++++++++++++++++++++- src/choosenimpkg/switcher.nim | 2 +- src/choosenimpkg/utils.nim | 24 ------------------------ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/choosenimpkg/download.nim b/src/choosenimpkg/download.nim index 450f3db..b4308d2 100644 --- a/src/choosenimpkg/download.nim +++ b/src/choosenimpkg/download.nim @@ -7,7 +7,7 @@ import nimblepkg/[version, cli] when defined(curl): import libcurl except Version -import cliparams, common, utils +import cliparams, common, utils, switcher # import telemetry const @@ -28,6 +28,35 @@ const # Windows-only const progressBarLength = 50 + +proc getNightliesUrl(parsedContents: JsonNode, arch: int): (string, string) = + let os = + when defined(windows): "windows" + elif defined(linux): "linux" + elif defined(macosx): "osx" + elif defined(freebsd): "freebsd" + for jn in parsedContents.getElems(): + if jn["name"].getStr().contains("devel"): + let tagName = jn{"tag_name"}.getStr("") + for asset in jn["assets"].getElems(): + let aname = asset["name"].getStr() + let url = asset{"browser_download_url"}.getStr("") + if os in aname: + when not defined(macosx): + if "x" & $arch in aname: + result = (url, tagName) + else: + if isAppleSilicon(): + if "arm64" in aname: + result = (url, tagName) + else: + if "amd64" in aname: + result = (url, tagName) + if result[0].len != 0: + break + if result[0].len != 0: + break + proc showIndeterminateBar(progress, speed: BiggestInt, lastPos: var int) = try: eraseLine() diff --git a/src/choosenimpkg/switcher.nim b/src/choosenimpkg/switcher.nim index 9ea47c4..44028b9 100644 --- a/src/choosenimpkg/switcher.nim +++ b/src/choosenimpkg/switcher.nim @@ -1,4 +1,4 @@ -import os, strutils, osproc, pegs +import std/[os, strutils, osproc, pegs, json] import nimblepkg/[cli, version, options] from nimblepkg/tools import getNameVersionChecksum diff --git a/src/choosenimpkg/utils.nim b/src/choosenimpkg/utils.nim index 9280c4c..8e5c149 100644 --- a/src/choosenimpkg/utils.nim +++ b/src/choosenimpkg/utils.nim @@ -180,27 +180,3 @@ proc getLatestCommit*(repo, branch: string): string = break else: display("Warning", outp & "\ngit ls-remote failed", Warning, HighPriority) - -proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) = - let os = - when defined(windows): "windows" - elif defined(linux): "linux" - elif defined(macosx): "osx" - elif defined(freebsd): "freebsd" - for jn in parsedContents.getElems(): - if jn["name"].getStr().contains("devel"): - let tagName = jn{"tag_name"}.getStr("") - for asset in jn["assets"].getElems(): - let aname = asset["name"].getStr() - let url = asset{"browser_download_url"}.getStr("") - if os in aname: - when not defined(macosx): - if "x" & $arch in aname: - result = (url, tagName) - else: - if $hostCPU in aname: - result = (url, tagName) - if result[0].len != 0: - break - if result[0].len != 0: - break