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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
}"
|
||||
];
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user