nim: deprecate and move os and cpu to stdenv.targetPlatform.nim
This change makes it more accesssable to using nim cpu and os without referencing nim.
This commit is contained in:
@@ -621,6 +621,64 @@ let
|
||||
else
|
||||
null;
|
||||
};
|
||||
|
||||
nim = {
|
||||
# See these locations for a known list of cpu/os idntifeiers:
|
||||
# - https://nim-lang.org/docs/system.html#hostCPU
|
||||
# - https://nim-lang.org/docs/system.html#hostOS
|
||||
cpu =
|
||||
if final.isAarch32 then
|
||||
"arm"
|
||||
else if final.isAarch64 then
|
||||
"arm64"
|
||||
else if final.isAlpha then
|
||||
"alpha"
|
||||
else if final.isAvr then
|
||||
"avr"
|
||||
else if final.isMips && final.is32Bit then
|
||||
"mips"
|
||||
else if final.isMips && final.is64Bit then
|
||||
"mips64"
|
||||
else if final.isMsp430 then
|
||||
"msp430"
|
||||
else if final.isPower && final.is32bit then
|
||||
"powerpc"
|
||||
else if final.isPower && final.is64bit then
|
||||
"powerpc64"
|
||||
else if final.isRiscV && final.is64bit then
|
||||
"riscv64"
|
||||
else if final.isSparc then
|
||||
"sparc"
|
||||
else if final.isx86_32 then
|
||||
"i386"
|
||||
else if final.isx86_64 then
|
||||
"amd64"
|
||||
else
|
||||
null;
|
||||
os =
|
||||
if final.isAndroid then
|
||||
"Android"
|
||||
else if final.isDarwin then
|
||||
"MacOSX"
|
||||
else if final.isFreeBSD then
|
||||
"FreeBSD"
|
||||
else if final.isGenode then
|
||||
"Genode"
|
||||
else if final.isLinux then
|
||||
"Linux"
|
||||
else if final.isNetBSD then
|
||||
"NetBSD"
|
||||
else if final.isNone then
|
||||
"Standalone"
|
||||
else if final.isOpenBSD then
|
||||
"OpenBSD"
|
||||
else if final.isWindows then
|
||||
"Windows"
|
||||
else if final.isiOS then
|
||||
"iOS"
|
||||
else
|
||||
null;
|
||||
};
|
||||
};
|
||||
in
|
||||
assert final.useAndroidPrebuilt -> final.isAndroid;
|
||||
|
||||
@@ -48,8 +48,8 @@ let
|
||||
runHook preBuild
|
||||
cat >> config/config.nims << WTF
|
||||
|
||||
switch("os", "${nimUnwrapped.passthru.nimTarget.os}")
|
||||
switch("cpu", "${nimUnwrapped.passthru.nimTarget.cpu}")
|
||||
switch("os", "${stdenv.targetPlatform.nim.os}")
|
||||
switch("cpu", "${stdenv.targetPlatform.nim.cpu}")
|
||||
switch("define", "nixbuild")
|
||||
|
||||
# Configure the compiler using the $CC set by Nix at build time
|
||||
@@ -63,8 +63,8 @@ let
|
||||
|
||||
mv config/nim.cfg config/nim.cfg.old
|
||||
cat > config/nim.cfg << WTF
|
||||
os = "${nimUnwrapped.passthru.nimTarget.os}"
|
||||
cpu = "${nimUnwrapped.passthru.nimTarget.cpu}"
|
||||
os = "${stdenv.targetPlatform.nim.os}"
|
||||
cpu = "${stdenv.targetPlatform.nim.cpu}"
|
||||
define:"nixbuild"
|
||||
WTF
|
||||
|
||||
|
||||
@@ -11,77 +11,6 @@
|
||||
sqlite,
|
||||
darwin,
|
||||
}:
|
||||
|
||||
let
|
||||
parseCpu =
|
||||
platform:
|
||||
with platform;
|
||||
# Derive a Nim CPU identifier
|
||||
if isAarch32 then
|
||||
"arm"
|
||||
else if isAarch64 then
|
||||
"arm64"
|
||||
else if isAlpha then
|
||||
"alpha"
|
||||
else if isAvr then
|
||||
"avr"
|
||||
else if isMips && is32bit then
|
||||
"mips"
|
||||
else if isMips && is64bit then
|
||||
"mips64"
|
||||
else if isMsp430 then
|
||||
"msp430"
|
||||
else if isPower && is32bit then
|
||||
"powerpc"
|
||||
else if isPower && is64bit then
|
||||
"powerpc64"
|
||||
else if isRiscV && is64bit then
|
||||
"riscv64"
|
||||
else if isSparc then
|
||||
"sparc"
|
||||
else if isx86_32 then
|
||||
"i386"
|
||||
else if isx86_64 then
|
||||
"amd64"
|
||||
else
|
||||
throw "no Nim CPU support known for ${config}";
|
||||
|
||||
parseOs =
|
||||
platform:
|
||||
with platform;
|
||||
# Derive a Nim OS identifier
|
||||
if isAndroid then
|
||||
"Android"
|
||||
else if isDarwin then
|
||||
"MacOSX"
|
||||
else if isFreeBSD then
|
||||
"FreeBSD"
|
||||
else if isGenode then
|
||||
"Genode"
|
||||
else if isLinux then
|
||||
"Linux"
|
||||
else if isNetBSD then
|
||||
"NetBSD"
|
||||
else if isNone then
|
||||
"Standalone"
|
||||
else if isOpenBSD then
|
||||
"OpenBSD"
|
||||
else if isWindows then
|
||||
"Windows"
|
||||
else if isiOS then
|
||||
"iOS"
|
||||
else
|
||||
throw "no Nim OS support known for ${config}";
|
||||
|
||||
parsePlatform = p: {
|
||||
cpu = parseCpu p;
|
||||
os = parseOs p;
|
||||
};
|
||||
|
||||
nimHost = parsePlatform stdenv.hostPlatform;
|
||||
nimTarget = parsePlatform stdenv.targetPlatform;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "nim-unwrapped";
|
||||
version = "2.2.4";
|
||||
@@ -135,8 +64,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
kochArgs = [
|
||||
"--cpu:${nimHost.cpu}"
|
||||
"--os:${nimHost.os}"
|
||||
"--cpu:${stdenv.hostPlatform.nim.cpu}"
|
||||
"--os:${stdenv.hostPlatform.nim.os}"
|
||||
"-d:release"
|
||||
"-d:useGnuReadline"
|
||||
]
|
||||
@@ -168,7 +97,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit nimHost nimTarget;
|
||||
nimHost = lib.warn "nimHost is deprecated, please use stdenv.hostPlatform.nim.os instead." stdenv.hostPlatform.nim.os;
|
||||
nimTarget = lib.warn "nimTarget is deprecated, please use stdenv.hostPlatform.nim.cpu instead." stdenv.hostPlatform.cpu;
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
Reference in New Issue
Block a user