summaryrefslogtreecommitdiffstats
path: root/lib/systems/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/systems/default.nix')
-rw-r--r--lib/systems/default.nix31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index 77f200952958..8aa413f53817 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -3,7 +3,6 @@
rec {
doubles = import ./doubles.nix { inherit lib; };
- forMeta = import ./for-meta.nix { inherit lib; };
parse = import ./parse.nix { inherit lib; };
inspect = import ./inspect.nix { inherit lib; };
platforms = import ./platforms.nix { inherit lib; };
@@ -15,7 +14,9 @@ rec {
# `parsed` is inferred from args, both because there are two options with one
# clearly prefered, and to prevent cycles. A simpler fixed point where the RHS
# always just used `final.*` would fail on both counts.
- elaborate = args: let
+ elaborate = args': let
+ args = if lib.isString args' then { system = args'; }
+ else args';
final = {
# Prefer to parse `config` as it is strictly more informative.
parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);
@@ -24,15 +25,20 @@ rec {
config = parse.tripleFromSystem final.parsed;
# Just a guess, based on `system`
platform = platforms.selectBySystem final.system;
+ # Determine whether we are compatible with the provided CPU
+ isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
# Derived meta-data
libc =
/**/ if final.isDarwin then "libSystem"
else if final.isMinGW then "msvcrt"
+ else if final.isWasi then "wasilibc"
else if final.isMusl then "musl"
else if final.isUClibc then "uclibc"
else if final.isAndroid then "bionic"
else if final.isLinux /* default */ then "glibc"
+ else if final.isMsp430 then "newlib"
else if final.isAvr then "avrlibc"
+ else if final.isNetBSD then "nblibc"
# TODO(@Ericson2314) think more about other operating systems
else "native/impure";
extensions = {
@@ -58,7 +64,7 @@ rec {
"netbsd" = "NetBSD";
"freebsd" = "FreeBSD";
"openbsd" = "OpenBSD";
- "wasm" = "Wasm";
+ "wasi" = "Wasi";
}.${final.parsed.kernel.name} or null;
# uname -p
@@ -68,16 +74,22 @@ rec {
release = null;
};
+ kernelArch =
+ if final.isAarch32 then "arm"
+ else if final.isAarch64 then "arm64"
+ else if final.isx86_32 then "x86"
+ else if final.isx86_64 then "ia64"
+ else final.parsed.cpu.name;
+
qemuArch =
if final.isArm then "arm"
else if final.isx86_64 then "x86_64"
else if final.isx86 then "i386"
else {
"powerpc" = "ppc";
+ "powerpcle" = "ppc";
"powerpc64" = "ppc64";
- "powerpc64le" = "ppc64";
- "mips64" = "mips";
- "mipsel64" = "mipsel";
+ "powerpc64le" = "ppc64le";
}.${final.parsed.cpu.name} or final.parsed.cpu.name;
emulator = pkgs: let
@@ -98,13 +110,14 @@ rec {
wine = (pkgs.winePackagesFor wine-name).minimal;
in
if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
- (final.parsed.cpu.name == pkgs.stdenv.hostPlatform.parsed.cpu.name ||
- (final.isi686 && pkgs.stdenv.hostPlatform.isx86_64))
- then pkgs.runtimeShell
+ pkgs.stdenv.hostPlatform.isCompatible final
+ then "${pkgs.runtimeShell} -c '\"$@\"' --"
else if final.isWindows
then "${wine}/bin/${wine-name}"
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
then "${qemu-user}/bin/qemu-${final.qemuArch}"
+ else if final.isWasi
+ then "${pkgs.wasmtime}/bin/wasmtime"
else throw "Don't know how to run ${final.config} executables.";
} // mapAttrs (n: v: v final.parsed) inspect.predicates