From 08547129de58b4a48fd1e6e25a8cd079c2f316e6 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 6 Dec 2024 04:01:59 +0200 Subject: [PATCH] DONTDROP treewide: Change unnecessary aborts to throws `throw`s are better because they don't abort evaluation when evaluating the whole set. Fixes `error: evaluation aborted with the following error message: 'Unsupported platform: arm64.'` on linux cross from darwin --- pkgs/applications/networking/cluster/k3s/builder.nix | 8 ++++---- pkgs/by-name/de/debase/package.nix | 2 +- pkgs/by-name/ni/nim-unwrapped-2_2/package.nix | 4 ++-- pkgs/by-name/vi/virtual-ans/package.nix | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index abf25306acab1f..c19bf46fa263bd 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -137,7 +137,7 @@ let s: mutFirstChar lib.toLower (lib.concatMapStrings (mutFirstChar lib.toUpper) (lib.splitString "-" s)); - # finds the images archive for the desired architecture, aborts in case no suitable archive is found + # finds the images archive for the desired architecture, throws in case no suitable archive is found findImagesArchive = arch: let @@ -145,17 +145,17 @@ let in lib.findFirst ( n: lib.hasInfix arch n - ) (abort "k3s: no airgap images for ${arch} available") imagesVersionsNames; + ) (throw "k3s: no airgap images for ${arch} available") imagesVersionsNames; # a shortcut that provides the images archive for the host platform. Currently only supports - # aarch64 (arm64) and x86_64 (amd64), aborts on other architectures. + # aarch64 (arm64) and x86_64 (amd64), throws on other architectures. airgapImages = fetchurl ( if stdenv.hostPlatform.isAarch64 then imagesVersions.${findImagesArchive "arm64"} else if stdenv.hostPlatform.isx86_64 then imagesVersions.${findImagesArchive "amd64"} else - abort "k3s: airgap images cannot be found automatically for architecture ${stdenv.hostPlatform.linuxArch}, consider using an image archive with an explicit architecture." + throw "k3s: airgap images cannot be found automatically for architecture ${stdenv.hostPlatform.linuxArch}, consider using an image archive with an explicit architecture." ); # so, k3s is a complicated thing to package diff --git a/pkgs/by-name/de/debase/package.nix b/pkgs/by-name/de/debase/package.nix index 1b300f1e21de5e..70be9b81eed637 100644 --- a/pkgs/by-name/de/debase/package.nix +++ b/pkgs/by-name/de/debase/package.nix @@ -72,7 +72,7 @@ stdenv.mkDerivation rec { else if stdenv.hostPlatform.isAarch64 then "arm64" else - abort "unsupported system: ${stdenv.system}" + throw "unsupported system: ${stdenv.system}" }" ]; diff --git a/pkgs/by-name/ni/nim-unwrapped-2_2/package.nix b/pkgs/by-name/ni/nim-unwrapped-2_2/package.nix index 311c0f5b9d8068..41307f32027155 100644 --- a/pkgs/by-name/ni/nim-unwrapped-2_2/package.nix +++ b/pkgs/by-name/ni/nim-unwrapped-2_2/package.nix @@ -45,7 +45,7 @@ let else if isx86_64 then "amd64" else - abort "no Nim CPU support known for ${config}"; + throw "no Nim CPU support known for ${config}"; parseOs = platform: @@ -72,7 +72,7 @@ let else if isiOS then "iOS" else - abort "no Nim OS support known for ${config}"; + throw "no Nim OS support known for ${config}"; parsePlatform = p: { cpu = parseCpu p; diff --git a/pkgs/by-name/vi/virtual-ans/package.nix b/pkgs/by-name/vi/virtual-ans/package.nix index 4a7467da125d6b..e71bc00e3042b1 100644 --- a/pkgs/by-name/vi/virtual-ans/package.nix +++ b/pkgs/by-name/vi/virtual-ans/package.nix @@ -46,7 +46,7 @@ stdenv.mkDerivation rec { startScript = if stdenv.hostPlatform.isx86_32 then "START_LINUX_X86" else if stdenv.hostPlatform.isx86_64 then "START_LINUX_X86_64" #else if stdenv.hostPlatform.isDarwin then "START_MACOS.app" # disabled because I cannot test on Darwin - else abort "Unsupported platform: ${stdenv.hostPlatform.linuxArch}."; + else throw "Unsupported platform: ${stdenv.hostPlatform.linuxArch}."; linuxExecutable = if stdenv.hostPlatform.isx86_32 then "pixilang_linux_x86" else if stdenv.hostPlatform.isx86_64 then "pixilang_linux_x86_64"