nodejs: split destCPU into stdenv.$platform.node
this architecture mapping is used broadly in the node ecosystem.
an assortment of tools and hooks, like buildNpmPackage or
pnpm.configHook, will benefit from reusing these values. placing them in
stdenv makes sense because (1) several of these tools don't currently
depend on nodejs, and may even be available where nodejs is not and (2)
`stdenv.{build,host,target}Platform` seems to be less error-prone than
`pkgs*.nodejs.{os,arch}` -- especially for setup hooks where the offsets
are shifted.
This commit is contained in:
@@ -562,6 +562,51 @@ let
|
||||
# See https://go.dev/wiki/GoArm
|
||||
GOARM = toString (lib.intersectLists [ (final.parsed.cpu.version or "") ] [ "5" "6" "7" ]);
|
||||
};
|
||||
|
||||
node = {
|
||||
# See these locations for a list of known architectures/platforms:
|
||||
# - https://nodejs.org/api/os.html#osarch
|
||||
# - https://nodejs.org/api/os.html#osplatform
|
||||
arch =
|
||||
if final.isAarch then
|
||||
"arm" + lib.optionalString final.is64bit "64"
|
||||
else if final.isMips32 then
|
||||
"mips" + lib.optionalString final.isLittleEndian "el"
|
||||
else if final.isMips64 && final.isLittleEndian then
|
||||
"mips64el"
|
||||
else if final.isPower then
|
||||
"ppc" + lib.optionalString final.is64bit "64"
|
||||
else if final.isx86_64 then
|
||||
"x64"
|
||||
else if final.isx86_32 then
|
||||
"ia32"
|
||||
else if final.isS390x then
|
||||
"s390x"
|
||||
else if final.isRiscV64 then
|
||||
"riscv64"
|
||||
else if final.isLoongArch64 then
|
||||
"loong64"
|
||||
else
|
||||
null;
|
||||
|
||||
platform =
|
||||
if final.isAndroid then
|
||||
"android"
|
||||
else if final.isDarwin then
|
||||
"darwin"
|
||||
else if final.isFreeBSD then
|
||||
"freebsd"
|
||||
else if final.isLinux then
|
||||
"linux"
|
||||
else if final.isOpenBSD then
|
||||
"openbsd"
|
||||
else if final.isSunOS then
|
||||
"sunos"
|
||||
else if final.isWindows then
|
||||
"win32"
|
||||
else
|
||||
null;
|
||||
};
|
||||
};
|
||||
in
|
||||
assert final.useAndroidPrebuilt -> final.isAndroid;
|
||||
|
||||
@@ -70,30 +70,6 @@ let
|
||||
"freebsd"
|
||||
else
|
||||
throw "unsupported os ${platform.uname.system}";
|
||||
destCPU =
|
||||
let
|
||||
platform = stdenv.hostPlatform;
|
||||
in
|
||||
if platform.isAarch then
|
||||
"arm" + lib.optionalString platform.is64bit "64"
|
||||
else if platform.isMips32 then
|
||||
"mips" + lib.optionalString platform.isLittleEndian "le"
|
||||
else if platform.isMips64 && platform.isLittleEndian then
|
||||
"mips64el"
|
||||
else if platform.isPower then
|
||||
"ppc" + lib.optionalString platform.is64bit "64"
|
||||
else if platform.isx86_64 then
|
||||
"x64"
|
||||
else if platform.isx86_32 then
|
||||
"ia32"
|
||||
else if platform.isS390x then
|
||||
"s390x"
|
||||
else if platform.isRiscV64 then
|
||||
"riscv64"
|
||||
else if platform.isLoongArch64 then
|
||||
"loong64"
|
||||
else
|
||||
throw "unsupported cpu ${platform.uname.processor}";
|
||||
destARMFPU =
|
||||
let
|
||||
platform = stdenv.hostPlatform;
|
||||
@@ -258,7 +234,7 @@ let
|
||||
# --cross-compiling flag enables use of CC_host et. al
|
||||
(if canExecute || canEmulate then "--no-cross-compiling" else "--cross-compiling")
|
||||
"--dest-os=${destOS}"
|
||||
"--dest-cpu=${destCPU}"
|
||||
"--dest-cpu=${stdenv.hostPlatform.node.arch}"
|
||||
]
|
||||
++ lib.optionals (destARMFPU != null) [ "--with-arm-fpu=${destARMFPU}" ]
|
||||
++ lib.optionals (destARMFloatABI != null) [ "--with-arm-float-abi=${destARMFloatABI}" ]
|
||||
|
||||
Reference in New Issue
Block a user