aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/lib/systems
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/lib/systems')
-rw-r--r--nixpkgs/lib/systems/default.nix134
-rw-r--r--nixpkgs/lib/systems/doubles.nix65
-rw-r--r--nixpkgs/lib/systems/examples.nix244
-rw-r--r--nixpkgs/lib/systems/inspect.nix67
-rw-r--r--nixpkgs/lib/systems/parse.nix447
-rw-r--r--nixpkgs/lib/systems/platforms.nix471
6 files changed, 1428 insertions, 0 deletions
diff --git a/nixpkgs/lib/systems/default.nix b/nixpkgs/lib/systems/default.nix
new file mode 100644
index 00000000000..0c0cdf1f11b
--- /dev/null
+++ b/nixpkgs/lib/systems/default.nix
@@ -0,0 +1,134 @@
+{ lib }:
+ let inherit (lib.attrsets) mapAttrs; in
+
+rec {
+ doubles = import ./doubles.nix { inherit lib; };
+ parse = import ./parse.nix { inherit lib; };
+ inspect = import ./inspect.nix { inherit lib; };
+ platforms = import ./platforms.nix { inherit lib; };
+ examples = import ./examples.nix { inherit lib; };
+
+ # Elaborate a `localSystem` or `crossSystem` so that it contains everything
+ # necessary.
+ #
+ # `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
+ 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);
+ # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
+ system = parse.doubleFromSystem final.parsed;
+ 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 = {
+ sharedLibrary =
+ /**/ if final.isDarwin then ".dylib"
+ else if final.isWindows then ".dll"
+ else ".so";
+ executable =
+ /**/ if final.isWindows then ".exe"
+ else "";
+ };
+ # Misc boolean options
+ useAndroidPrebuilt = false;
+ useiOSPrebuilt = false;
+
+ # Output from uname
+ uname = {
+ # uname -s
+ system = {
+ linux = "Linux";
+ windows = "Windows";
+ darwin = "Darwin";
+ netbsd = "NetBSD";
+ freebsd = "FreeBSD";
+ openbsd = "OpenBSD";
+ wasi = "Wasi";
+ }.${final.parsed.kernel.name} or null;
+
+ # uname -p
+ processor = final.parsed.cpu.name;
+
+ # uname -r
+ 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 = "ppc64le";
+ }.${final.parsed.cpu.name} or final.parsed.cpu.name;
+
+ emulator = pkgs: let
+ qemu-user = pkgs.qemu.override {
+ smartcardSupport = false;
+ spiceSupport = false;
+ openGLSupport = false;
+ virglSupport = false;
+ vncSupport = false;
+ gtkSupport = false;
+ sdlSupport = false;
+ pulseSupport = false;
+ smbdSupport = false;
+ seccompSupport = false;
+ hostCpuTargets = ["${final.qemuArch}-linux-user"];
+ };
+ wine-name = "wine${toString final.parsed.cpu.bits}";
+ wine = (pkgs.winePackagesFor wine-name).minimal;
+ in
+ if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
+ 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
+ // args;
+ in assert final.useAndroidPrebuilt -> final.isAndroid;
+ assert lib.foldl
+ (pass: { assertion, message }:
+ if assertion final
+ then pass
+ else throw message)
+ true
+ (final.parsed.abi.assertions or []);
+ final;
+}
diff --git a/nixpkgs/lib/systems/doubles.nix b/nixpkgs/lib/systems/doubles.nix
new file mode 100644
index 00000000000..8e02fcb5de0
--- /dev/null
+++ b/nixpkgs/lib/systems/doubles.nix
@@ -0,0 +1,65 @@
+{ lib }:
+let
+ inherit (lib) lists;
+ inherit (lib.systems) parse;
+ inherit (lib.systems.inspect) predicates;
+ inherit (lib.attrsets) matchAttrs;
+
+ all = [
+ "aarch64-linux"
+ "armv5tel-linux" "armv6l-linux" "armv7l-linux"
+
+ "mipsel-linux"
+
+ "i686-cygwin" "i686-freebsd" "i686-linux" "i686-netbsd" "i686-openbsd"
+
+ "x86_64-cygwin" "x86_64-freebsd" "x86_64-linux"
+ "x86_64-netbsd" "x86_64-openbsd" "x86_64-solaris"
+
+ "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin"
+
+ "x86_64-windows" "i686-windows"
+
+ "wasm64-wasi" "wasm32-wasi"
+
+ "powerpc64le-linux"
+
+ "riscv32-linux" "riscv64-linux"
+
+ "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none"
+ ];
+
+ allParsed = map parse.mkSystemFromString all;
+
+ filterDoubles = f: map parse.doubleFromSystem (lists.filter f allParsed);
+
+in {
+ inherit all;
+
+ none = [];
+
+ arm = filterDoubles predicates.isAarch32;
+ aarch64 = filterDoubles predicates.isAarch64;
+ x86 = filterDoubles predicates.isx86;
+ i686 = filterDoubles predicates.isi686;
+ x86_64 = filterDoubles predicates.isx86_64;
+ mips = filterDoubles predicates.isMips;
+ riscv = filterDoubles predicates.isRiscV;
+
+ cygwin = filterDoubles predicates.isCygwin;
+ darwin = filterDoubles predicates.isDarwin;
+ freebsd = filterDoubles predicates.isFreeBSD;
+ # Should be better, but MinGW is unclear.
+ gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; });
+ illumos = filterDoubles predicates.isSunOS;
+ linux = filterDoubles predicates.isLinux;
+ netbsd = filterDoubles predicates.isNetBSD;
+ openbsd = filterDoubles predicates.isOpenBSD;
+ unix = filterDoubles predicates.isUnix;
+ wasi = filterDoubles predicates.isWasi;
+ windows = filterDoubles predicates.isWindows;
+
+ embedded = filterDoubles predicates.isNone;
+
+ mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "armv7a-linux" "aarch64-linux" "powerpc64le-linux"];
+}
diff --git a/nixpkgs/lib/systems/examples.nix b/nixpkgs/lib/systems/examples.nix
new file mode 100644
index 00000000000..511ae197948
--- /dev/null
+++ b/nixpkgs/lib/systems/examples.nix
@@ -0,0 +1,244 @@
+# These can be passed to nixpkgs as either the `localSystem` or
+# `crossSystem`. They are put here for user convenience, but also used by cross
+# tests and linux cross stdenv building, so handle with care!
+{ lib }:
+let
+ platforms = import ./platforms.nix { inherit lib; };
+
+ riscv = bits: {
+ config = "riscv${bits}-unknown-linux-gnu";
+ platform = platforms.riscv-multiplatform bits;
+ };
+in
+
+rec {
+ #
+ # Linux
+ #
+ powernv = {
+ config = "powerpc64le-unknown-linux-gnu";
+ platform = platforms.powernv;
+ };
+ musl-power = {
+ config = "powerpc64le-unknown-linux-musl";
+ platform = platforms.powernv;
+ };
+
+ sheevaplug = {
+ config = "armv5tel-unknown-linux-gnueabi";
+ platform = platforms.sheevaplug;
+ };
+
+ raspberryPi = {
+ config = "armv6l-unknown-linux-gnueabihf";
+ platform = platforms.raspberrypi;
+ };
+
+ armv7l-hf-multiplatform = {
+ config = "armv7l-unknown-linux-gnueabihf";
+ platform = platforms.armv7l-hf-multiplatform;
+ };
+
+ aarch64-multiplatform = {
+ config = "aarch64-unknown-linux-gnu";
+ platform = platforms.aarch64-multiplatform;
+ };
+
+ armv7a-android-prebuilt = {
+ config = "armv7a-unknown-linux-androideabi";
+ sdkVer = "24";
+ ndkVer = "18b";
+ platform = platforms.armv7a-android;
+ useAndroidPrebuilt = true;
+ };
+
+ aarch64-android-prebuilt = {
+ config = "aarch64-unknown-linux-android";
+ sdkVer = "24";
+ ndkVer = "18b";
+ platform = platforms.aarch64-multiplatform;
+ useAndroidPrebuilt = true;
+ };
+
+ scaleway-c1 = armv7l-hf-multiplatform // rec {
+ platform = platforms.scaleway-c1;
+ inherit (platform.gcc) fpu;
+ };
+
+ pogoplug4 = {
+ config = "armv5tel-unknown-linux-gnueabi";
+ platform = platforms.pogoplug4;
+ };
+
+ ben-nanonote = {
+ config = "mipsel-unknown-linux-uclibc";
+ platform = platforms.ben_nanonote;
+ };
+
+ fuloongminipc = {
+ config = "mipsel-unknown-linux-gnu";
+ platform = platforms.fuloong2f_n32;
+ };
+
+ muslpi = raspberryPi // {
+ config = "armv6l-unknown-linux-musleabihf";
+ };
+
+ aarch64-multiplatform-musl = aarch64-multiplatform // {
+ config = "aarch64-unknown-linux-musl";
+ };
+
+ gnu64 = { config = "x86_64-unknown-linux-gnu"; };
+ gnu32 = { config = "i686-unknown-linux-gnu"; };
+
+ musl64 = { config = "x86_64-unknown-linux-musl"; };
+ musl32 = { config = "i686-unknown-linux-musl"; };
+
+ riscv64 = riscv "64";
+ riscv32 = riscv "32";
+
+ riscv64-embedded = {
+ config = "riscv64-none-elf";
+ libc = "newlib";
+ platform = platforms.riscv-multiplatform "64";
+ };
+
+ riscv32-embedded = {
+ config = "riscv32-none-elf";
+ libc = "newlib";
+ platform = platforms.riscv-multiplatform "32";
+ };
+
+ msp430 = {
+ config = "msp430-elf";
+ libc = "newlib";
+ };
+
+ avr = {
+ config = "avr";
+ };
+
+ arm-embedded = {
+ config = "arm-none-eabi";
+ libc = "newlib";
+ };
+ armhf-embedded = {
+ config = "arm-none-eabihf";
+ libc = "newlib";
+ };
+
+ aarch64-embedded = {
+ config = "aarch64-none-elf";
+ libc = "newlib";
+ };
+
+ aarch64be-embedded = {
+ config = "aarch64_be-none-elf";
+ libc = "newlib";
+ };
+
+ ppc-embedded = {
+ config = "powerpc-none-eabi";
+ libc = "newlib";
+ };
+
+ ppcle-embedded = {
+ config = "powerpcle-none-eabi";
+ libc = "newlib";
+ };
+
+ i686-embedded = {
+ config = "i686-elf";
+ libc = "newlib";
+ };
+
+ x86_64-embedded = {
+ config = "x86_64-elf";
+ libc = "newlib";
+ };
+
+ #
+ # Darwin
+ #
+
+ iphone64 = {
+ config = "aarch64-apple-ios";
+ # config = "aarch64-apple-darwin14";
+ sdkVer = "10.2";
+ xcodeVer = "8.2";
+ xcodePlatform = "iPhoneOS";
+ useiOSPrebuilt = true;
+ platform = {};
+ };
+
+ iphone32 = {
+ config = "armv7a-apple-ios";
+ # config = "arm-apple-darwin10";
+ sdkVer = "10.2";
+ xcodeVer = "8.2";
+ xcodePlatform = "iPhoneOS";
+ useiOSPrebuilt = true;
+ platform = {};
+ };
+
+ iphone64-simulator = {
+ config = "x86_64-apple-ios";
+ # config = "x86_64-apple-darwin14";
+ sdkVer = "10.2";
+ xcodeVer = "8.2";
+ xcodePlatform = "iPhoneSimulator";
+ useiOSPrebuilt = true;
+ platform = {};
+ };
+
+ iphone32-simulator = {
+ config = "i686-apple-ios";
+ # config = "i386-apple-darwin11";
+ sdkVer = "10.2";
+ xcodeVer = "8.2";
+ xcodePlatform = "iPhoneSimulator";
+ useiOSPrebuilt = true;
+ platform = {};
+ };
+
+ #
+ # Windows
+ #
+
+ # 32 bit mingw-w64
+ mingw32 = {
+ config = "i686-pc-mingw32";
+ libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
+ platform = {};
+ };
+
+ # 64 bit mingw-w64
+ mingwW64 = {
+ # That's the triplet they use in the mingw-w64 docs.
+ config = "x86_64-pc-mingw32";
+ libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
+ platform = {};
+ };
+
+ # BSDs
+
+ amd64-netbsd = {
+ config = "x86_64-unknown-netbsd";
+ libc = "nblibc";
+ };
+
+ #
+ # WASM
+ #
+
+ wasi32 = {
+ config = "wasm32-unknown-wasi";
+ useLLVM = true;
+ };
+
+ # Ghcjs
+ ghcjs = {
+ config = "js-unknown-ghcjs";
+ platform = {};
+ };
+}
diff --git a/nixpkgs/lib/systems/inspect.nix b/nixpkgs/lib/systems/inspect.nix
new file mode 100644
index 00000000000..8a983b3d363
--- /dev/null
+++ b/nixpkgs/lib/systems/inspect.nix
@@ -0,0 +1,67 @@
+{ lib }:
+with import ./parse.nix { inherit lib; };
+with lib.attrsets;
+with lib.lists;
+
+let abis_ = abis; in
+let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in
+
+rec {
+ patterns = rec {
+ isi686 = { cpu = cpuTypes.i686; };
+ isx86_32 = { cpu = { family = "x86"; bits = 32; }; };
+ isx86_64 = { cpu = { family = "x86"; bits = 64; }; };
+ isPowerPC = { cpu = cpuTypes.powerpc; };
+ isPower = { cpu = { family = "power"; }; };
+ isx86 = { cpu = { family = "x86"; }; };
+ isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
+ isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
+ isMips = { cpu = { family = "mips"; }; };
+ isRiscV = { cpu = { family = "riscv"; }; };
+ isSparc = { cpu = { family = "sparc"; }; };
+ isWasm = { cpu = { family = "wasm"; }; };
+ isMsp430 = { cpu = { family = "msp430"; }; };
+ isAvr = { cpu = { family = "avr"; }; };
+ isAlpha = { cpu = { family = "alpha"; }; };
+ isJavaScript = { cpu = cpuTypes.js; };
+
+ is32bit = { cpu = { bits = 32; }; };
+ is64bit = { cpu = { bits = 64; }; };
+ isBigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
+ isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
+
+ isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
+ isDarwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
+ isUnix = [ isBSD isDarwin isLinux isSunOS isCygwin ];
+
+ isMacOS = { kernel = kernels.macos; };
+ isiOS = { kernel = kernels.ios; };
+ isLinux = { kernel = kernels.linux; };
+ isSunOS = { kernel = kernels.solaris; };
+ isFreeBSD = { kernel = kernels.freebsd; };
+ isNetBSD = { kernel = kernels.netbsd; };
+ isOpenBSD = { kernel = kernels.openbsd; };
+ isWindows = { kernel = kernels.windows; };
+ isCygwin = { kernel = kernels.windows; abi = abis.cygnus; };
+ isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
+ isWasi = { kernel = kernels.wasi; };
+ isGhcjs = { kernel = kernels.ghcjs; };
+ isNone = { kernel = kernels.none; };
+
+ isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
+ isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];
+ isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ];
+
+ isEfi = map (family: { cpu.family = family; })
+ [ "x86" "arm" "aarch64" ];
+
+ # Deprecated after 18.03
+ isArm = isAarch32;
+ };
+
+ matchAnyAttrs = patterns:
+ if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
+ else matchAttrs patterns;
+
+ predicates = mapAttrs (_: matchAnyAttrs) patterns;
+}
diff --git a/nixpkgs/lib/systems/parse.nix b/nixpkgs/lib/systems/parse.nix
new file mode 100644
index 00000000000..5e12df32ffd
--- /dev/null
+++ b/nixpkgs/lib/systems/parse.nix
@@ -0,0 +1,447 @@
+# Define the list of system with their properties.
+#
+# See https://clang.llvm.org/docs/CrossCompilation.html and
+# http://llvm.org/docs/doxygen/html/Triple_8cpp_source.html especially
+# Triple::normalize. Parsing should essentially act as a more conservative
+# version of that last function.
+#
+# Most of the types below come in "open" and "closed" pairs. The open ones
+# specify what information we need to know about systems in general, and the
+# closed ones are sub-types representing the whitelist of systems we support in
+# practice.
+#
+# Code in the remainder of nixpkgs shouldn't rely on the closed ones in
+# e.g. exhaustive cases. Its more a sanity check to make sure nobody defines
+# systems that overlap with existing ones and won't notice something amiss.
+#
+{ lib }:
+with lib.lists;
+with lib.types;
+with lib.attrsets;
+with lib.strings;
+with (import ./inspect.nix { inherit lib; }).predicates;
+
+let
+ inherit (lib.options) mergeOneOption;
+
+ setTypes = type:
+ mapAttrs (name: value:
+ assert type.check value;
+ setType type.name ({ inherit name; } // value));
+
+in
+
+rec {
+
+ ################################################################################
+
+ types.openSignificantByte = mkOptionType {
+ name = "significant-byte";
+ description = "Endianness";
+ merge = mergeOneOption;
+ };
+
+ types.significantByte = enum (attrValues significantBytes);
+
+ significantBytes = setTypes types.openSignificantByte {
+ bigEndian = {};
+ littleEndian = {};
+ };
+
+ ################################################################################
+
+ # Reasonable power of 2
+ types.bitWidth = enum [ 8 16 32 64 128 ];
+
+ ################################################################################
+
+ types.openCpuType = mkOptionType {
+ name = "cpu-type";
+ description = "instruction set architecture name and information";
+ merge = mergeOneOption;
+ check = x: types.bitWidth.check x.bits
+ && (if 8 < x.bits
+ then types.significantByte.check x.significantByte
+ else !(x ? significantByte));
+ };
+
+ types.cpuType = enum (attrValues cpuTypes);
+
+ cpuTypes = with significantBytes; setTypes types.openCpuType {
+ arm = { bits = 32; significantByte = littleEndian; family = "arm"; };
+ armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; version = "5"; arch = "armv5t"; };
+ armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; arch = "armv6-m"; };
+ armv6l = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; arch = "armv6"; };
+ armv7a = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; arch = "armv7-a"; };
+ armv7r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; arch = "armv7-r"; };
+ armv7m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; arch = "armv7-m"; };
+ armv7l = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; arch = "armv7"; };
+ armv8a = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; arch = "armv8-a"; };
+ armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; arch = "armv8-a"; };
+ armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; arch = "armv8-m"; };
+ aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; version = "8"; arch = "armv8-a"; };
+ aarch64_be = { bits = 64; significantByte = bigEndian; family = "arm"; version = "8"; arch = "armv8-a"; };
+
+ i386 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i386"; };
+ i486 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i486"; };
+ i586 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i586"; };
+ i686 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i686"; };
+ x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; arch = "x86-64"; };
+
+ mips = { bits = 32; significantByte = bigEndian; family = "mips"; };
+ mipsel = { bits = 32; significantByte = littleEndian; family = "mips"; };
+ mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; };
+ mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
+
+ powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
+ powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
+ powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
+ powerpcle = { bits = 32; significantByte = littleEndian; family = "power"; };
+
+ riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; };
+ riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; };
+
+ sparc = { bits = 32; significantByte = bigEndian; family = "sparc"; };
+ sparc64 = { bits = 64; significantByte = bigEndian; family = "sparc"; };
+
+ wasm32 = { bits = 32; significantByte = littleEndian; family = "wasm"; };
+ wasm64 = { bits = 64; significantByte = littleEndian; family = "wasm"; };
+
+ alpha = { bits = 64; significantByte = littleEndian; family = "alpha"; };
+
+ msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; };
+ avr = { bits = 8; family = "avr"; };
+
+ js = { bits = 32; significantByte = littleEndian; family = "js"; };
+ };
+
+ # Determine where two CPUs are compatible with each other. That is,
+ # can we run code built for system b on system a? For that to
+ # happen, then the set of all possible possible programs that system
+ # b accepts must be a subset of the set of all programs that system
+ # a accepts. This compatibility relation forms a category where each
+ # CPU is an object and each arrow from a to b represents
+ # compatibility. CPUs with multiple modes of Endianness are
+ # isomorphic while all CPUs are endomorphic because any program
+ # built for a CPU can run on that CPU.
+ isCompatible = a: b: with cpuTypes; lib.any lib.id [
+ # x86
+ (b == i386 && isCompatible a i486)
+ (b == i486 && isCompatible a i586)
+ (b == i586 && isCompatible a i686)
+
+ # XXX: Not true in some cases. Like in WSL mode.
+ (b == i686 && isCompatible a x86_64)
+
+ # ARMv4
+ (b == arm && isCompatible a armv5tel)
+
+ # ARMv5
+ (b == armv5tel && isCompatible a armv6l)
+
+ # ARMv6
+ (b == armv6l && isCompatible a armv6m)
+ (b == armv6m && isCompatible a armv7l)
+
+ # ARMv7
+ (b == armv7l && isCompatible a armv7a)
+ (b == armv7l && isCompatible a armv7r)
+ (b == armv7l && isCompatible a armv7m)
+ (b == armv7a && isCompatible a armv8a)
+ (b == armv7r && isCompatible a armv8a)
+ (b == armv7m && isCompatible a armv8a)
+ (b == armv7a && isCompatible a armv8r)
+ (b == armv7r && isCompatible a armv8r)
+ (b == armv7m && isCompatible a armv8r)
+ (b == armv7a && isCompatible a armv8m)
+ (b == armv7r && isCompatible a armv8m)
+ (b == armv7m && isCompatible a armv8m)
+
+ # ARMv8
+ (b == armv8r && isCompatible a armv8a)
+ (b == armv8m && isCompatible a armv8a)
+
+ # XXX: not always true! Some arm64 cpus don’t support arm32 mode.
+ (b == aarch64 && a == armv8a)
+ (b == armv8a && isCompatible a aarch64)
+
+ (b == aarch64 && a == aarch64_be)
+ (b == aarch64_be && isCompatible a aarch64)
+
+ # PowerPC
+ (b == powerpc && isCompatible a powerpc64)
+ (b == powerpcle && isCompatible a powerpc)
+ (b == powerpc && a == powerpcle)
+ (b == powerpc64le && isCompatible a powerpc64)
+ (b == powerpc64 && a == powerpc64le)
+
+ # MIPS
+ (b == mips && isCompatible a mips64)
+ (b == mips && a == mipsel)
+ (b == mipsel && isCompatible a mips)
+ (b == mips64 && a == mips64el)
+ (b == mips64el && isCompatible a mips64)
+
+ # RISCV
+ (b == riscv32 && isCompatible a riscv64)
+
+ # SPARC
+ (b == sparc && isCompatible a sparc64)
+
+ # WASM
+ (b == wasm32 && isCompatible a wasm64)
+
+ # identity
+ (b == a)
+ ];
+
+ ################################################################################
+
+ types.openVendor = mkOptionType {
+ name = "vendor";
+ description = "vendor for the platform";
+ merge = mergeOneOption;
+ };
+
+ types.vendor = enum (attrValues vendors);
+
+ vendors = setTypes types.openVendor {
+ apple = {};
+ pc = {};
+
+ none = {};
+ unknown = {};
+ };
+
+ ################################################################################
+
+ types.openExecFormat = mkOptionType {
+ name = "exec-format";
+ description = "executable container used by the kernel";
+ merge = mergeOneOption;
+ };
+
+ types.execFormat = enum (attrValues execFormats);
+
+ execFormats = setTypes types.openExecFormat {
+ aout = {}; # a.out
+ elf = {};
+ macho = {};
+ pe = {};
+ wasm = {};
+
+ unknown = {};
+ };
+
+ ################################################################################
+
+ types.openKernelFamily = mkOptionType {
+ name = "exec-format";
+ description = "executable container used by the kernel";
+ merge = mergeOneOption;
+ };
+
+ types.kernelFamily = enum (attrValues kernelFamilies);
+
+ kernelFamilies = setTypes types.openKernelFamily {
+ bsd = {};
+ darwin = {};
+ };
+
+ ################################################################################
+
+ types.openKernel = mkOptionType {
+ name = "kernel";
+ description = "kernel name and information";
+ merge = mergeOneOption;
+ check = x: types.execFormat.check x.execFormat
+ && all types.kernelFamily.check (attrValues x.families);
+ };
+
+ types.kernel = enum (attrValues kernels);
+
+ kernels = with execFormats; with kernelFamilies; setTypes types.openKernel {
+ # TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as
+ # the nnormalized name for macOS.
+ macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
+ ios = { execFormat = macho; families = { inherit darwin; }; };
+ freebsd = { execFormat = elf; families = { inherit bsd; }; };
+ linux = { execFormat = elf; families = { }; };
+ netbsd = { execFormat = elf; families = { inherit bsd; }; };
+ none = { execFormat = unknown; families = { }; };
+ openbsd = { execFormat = elf; families = { inherit bsd; }; };
+ solaris = { execFormat = elf; families = { }; };
+ wasi = { execFormat = wasm; families = { }; };
+ windows = { execFormat = pe; families = { }; };
+ ghcjs = { execFormat = unknown; families = { }; };
+ } // { # aliases
+ # 'darwin' is the kernel for all of them. We choose macOS by default.
+ darwin = kernels.macos;
+ watchos = kernels.ios;
+ tvos = kernels.ios;
+ win32 = kernels.windows;
+ };
+
+ ################################################################################
+
+ types.openAbi = mkOptionType {
+ name = "abi";
+ description = "binary interface for compiled code and syscalls";
+ merge = mergeOneOption;
+ };
+
+ types.abi = enum (attrValues abis);
+
+ abis = setTypes types.openAbi {
+ cygnus = {};
+ msvc = {};
+
+ # Note: eabi is specific to ARM and PowerPC.
+ # On PowerPC, this corresponds to PPCEABI.
+ # On ARM, this corresponds to ARMEABI.
+ eabi = { float = "soft"; };
+ eabihf = { float = "hard"; };
+
+ # Other architectures should use ELF in embedded situations.
+ elf = {};
+
+ androideabi = {};
+ android = {
+ assertions = [
+ { assertion = platform: !platform.isAarch32;
+ message = ''
+ The "android" ABI is not for 32-bit ARM. Use "androideabi" instead.
+ '';
+ }
+ ];
+ };
+
+ gnueabi = { float = "soft"; };
+ gnueabihf = { float = "hard"; };
+ gnu = {
+ assertions = [
+ { assertion = platform: !platform.isAarch32;
+ message = ''
+ The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead.
+ '';
+ }
+ ];
+ };
+
+ musleabi = { float = "soft"; };
+ musleabihf = { float = "hard"; };
+ musl = {};
+
+ uclibceabihf = { float = "soft"; };
+ uclibceabi = { float = "hard"; };
+ uclibc = {};
+
+ unknown = {};
+ };
+
+ ################################################################################
+
+ types.parsedPlatform = mkOptionType {
+ name = "system";
+ description = "fully parsed representation of llvm- or nix-style platform tuple";
+ merge = mergeOneOption;
+ check = { cpu, vendor, kernel, abi }:
+ types.cpuType.check cpu
+ && types.vendor.check vendor
+ && types.kernel.check kernel
+ && types.abi.check abi;
+ };
+
+ isSystem = isType "system";
+
+ mkSystem = components:
+ assert types.parsedPlatform.check components;
+ setType "system" components;
+
+ mkSkeletonFromList = l: {
+ "1" = if elemAt l 0 == "avr"
+ then { cpu = elemAt l 0; kernel = "none"; abi = "unknown"; }
+ else throw "Target specification with 1 components is ambiguous";
+ "2" = # We only do 2-part hacks for things Nix already supports
+ if elemAt l 1 == "cygwin"
+ then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; }
+ # MSVC ought to be the default ABI so this case isn't needed. But then it
+ # becomes difficult to handle the gnu* variants for Aarch32 correctly for
+ # minGW. So it's easier to make gnu* the default for the MinGW, but
+ # hack-in MSVC for the non-MinGW case right here.
+ else if elemAt l 1 == "windows"
+ then { cpu = elemAt l 0; kernel = "windows"; abi = "msvc"; }
+ else if (elemAt l 1) == "elf"
+ then { cpu = elemAt l 0; vendor = "unknown"; kernel = "none"; abi = elemAt l 1; }
+ else { cpu = elemAt l 0; kernel = elemAt l 1; };
+ "3" = # Awkwards hacks, beware!
+ if elemAt l 1 == "apple"
+ then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
+ else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
+ then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; }
+ else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; }
+ else if (elemAt l 2 == "wasi")
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; }
+ else if hasPrefix "netbsd" (elemAt l 2)
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
+ else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"])
+ then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; }
+ else if (elemAt l 2 == "ghcjs")
+ then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 2; }
+ else throw "Target specification with 3 components is ambiguous";
+ "4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
+ }.${toString (length l)}
+ or (throw "system string has invalid number of hyphen-separated components");
+
+ # This should revert the job done by config.guess from the gcc compiler.
+ mkSystemFromSkeleton = { cpu
+ , # Optional, but fallback too complex for here.
+ # Inferred below instead.
+ vendor ? assert false; null
+ , kernel
+ , # Also inferred below
+ abi ? assert false; null
+ } @ args: let
+ getCpu = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
+ getVendor = name: vendors.${name} or (throw "Unknown vendor: ${name}");
+ getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}");
+ getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}");
+
+ parsed = {
+ cpu = getCpu args.cpu;
+ vendor =
+ /**/ if args ? vendor then getVendor args.vendor
+ else if isDarwin parsed then vendors.apple
+ else if isWindows parsed then vendors.pc
+ else vendors.unknown;
+ kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin"
+ else if hasPrefix "netbsd" args.kernel then getKernel "netbsd"
+ else getKernel args.kernel;
+ abi =
+ /**/ if args ? abi then getAbi args.abi
+ else if isLinux parsed || isWindows parsed then
+ if isAarch32 parsed then
+ if lib.versionAtLeast (parsed.cpu.version or "0") "6"
+ then abis.gnueabihf
+ else abis.gnueabi
+ else abis.gnu
+ else abis.unknown;
+ };
+
+ in mkSystem parsed;
+
+ mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
+
+ doubleFromSystem = { cpu, kernel, abi, ... }:
+ /**/ if abi == abis.cygnus then "${cpu.name}-cygwin"
+ else if kernel.families ? darwin then "${cpu.name}-darwin"
+ else "${cpu.name}-${kernel.name}";
+
+ tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
+ optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
+ in "${cpu.name}-${vendor.name}-${kernel.name}${optAbi}";
+
+ ################################################################################
+
+}
diff --git a/nixpkgs/lib/systems/platforms.nix b/nixpkgs/lib/systems/platforms.nix
new file mode 100644
index 00000000000..ab3cf1d5430
--- /dev/null
+++ b/nixpkgs/lib/systems/platforms.nix
@@ -0,0 +1,471 @@
+{ lib }:
+rec {
+ pcBase = {
+ name = "pc";
+ kernelBaseConfig = "defconfig";
+ # Build whatever possible as a module, if not stated in the extra config.
+ kernelAutoModules = true;
+ kernelTarget = "bzImage";
+ };
+
+ pc64 = pcBase // { kernelArch = "x86_64"; };
+
+ pc32 = pcBase // { kernelArch = "i386"; };
+
+ pc32_simplekernel = pc32 // {
+ kernelAutoModules = false;
+ };
+
+ pc64_simplekernel = pc64 // {
+ kernelAutoModules = false;
+ };
+
+ powernv = {
+ name = "PowerNV";
+ kernelArch = "powerpc";
+ kernelBaseConfig = "powernv_defconfig";
+ kernelTarget = "zImage";
+ kernelInstallTarget = "install";
+ kernelFile = "vmlinux";
+ kernelAutoModules = true;
+ # avoid driver/FS trouble arising from unusual page size
+ kernelExtraConfig = ''
+ PPC_64K_PAGES n
+ PPC_4K_PAGES y
+ IPV6 y
+ '';
+ };
+
+ ##
+ ## ARM
+ ##
+
+ pogoplug4 = {
+ name = "pogoplug4";
+
+ gcc = {
+ arch = "armv5te";
+ };
+
+ kernelMajor = "2.6";
+ kernelBaseConfig = "multi_v5_defconfig";
+ kernelArch = "arm";
+ kernelAutoModules = false;
+ kernelExtraConfig =
+ ''
+ # Ubi for the mtd
+ MTD_UBI y
+ UBIFS_FS y
+ UBIFS_FS_XATTR y
+ UBIFS_FS_ADVANCED_COMPR y
+ UBIFS_FS_LZO y
+ UBIFS_FS_ZLIB y
+ UBIFS_FS_DEBUG n
+ '';
+ kernelMakeFlags = [ "LOADADDR=0x8000" ];
+ kernelTarget = "uImage";
+ # TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working
+ #kernelDTB = true;
+ };
+
+ sheevaplug = {
+ name = "sheevaplug";
+ kernelMajor = "2.6";
+ kernelBaseConfig = "multi_v5_defconfig";
+ kernelArch = "arm";
+ kernelAutoModules = false;
+ kernelExtraConfig = ''
+ BLK_DEV_RAM y
+ BLK_DEV_INITRD y
+ BLK_DEV_CRYPTOLOOP m
+ BLK_DEV_DM m
+ DM_CRYPT m
+ MD y
+ REISERFS_FS m
+ BTRFS_FS m
+ XFS_FS m
+ JFS_FS m
+ EXT4_FS m
+ USB_STORAGE_CYPRESS_ATACB m
+
+ # mv cesa requires this sw fallback, for mv-sha1
+ CRYPTO_SHA1 y
+ # Fast crypto
+ CRYPTO_TWOFISH y
+ CRYPTO_TWOFISH_COMMON y
+ CRYPTO_BLOWFISH y
+ CRYPTO_BLOWFISH_COMMON y
+
+ IP_PNP y
+ IP_PNP_DHCP y
+ NFS_FS y
+ ROOT_NFS y
+ TUN m
+ NFS_V4 y
+ NFS_V4_1 y
+ NFS_FSCACHE y
+ NFSD m
+ NFSD_V2_ACL y
+ NFSD_V3 y
+ NFSD_V3_ACL y
+ NFSD_V4 y
+ NETFILTER y
+ IP_NF_IPTABLES y
+ IP_NF_FILTER y
+ IP_NF_MATCH_ADDRTYPE y
+ IP_NF_TARGET_LOG y
+ IP_NF_MANGLE y
+ IPV6 m
+ VLAN_8021Q m
+
+ CIFS y
+ CIFS_XATTR y
+ CIFS_POSIX y
+ CIFS_FSCACHE y
+ CIFS_ACL y
+
+ WATCHDOG y
+ WATCHDOG_CORE y
+ ORION_WATCHDOG m
+
+ ZRAM m
+ NETCONSOLE m
+
+ # Disable OABI to have seccomp_filter (required for systemd)
+ # https://github.com/raspberrypi/firmware/issues/651
+ OABI_COMPAT n
+
+ # Fail to build
+ DRM n
+ SCSI_ADVANSYS n
+ USB_ISP1362_HCD n
+ SND_SOC n
+ SND_ALI5451 n
+ FB_SAVAGE n
+ SCSI_NSP32 n
+ ATA_SFF n
+ SUNGEM n
+ IRDA n
+ ATM_HE n
+ SCSI_ACARD n
+ BLK_DEV_CMD640_ENHANCED n
+
+ FUSE_FS m
+
+ # systemd uses cgroups
+ CGROUPS y
+
+ # Latencytop
+ LATENCYTOP y
+
+ # Ubi for the mtd
+ MTD_UBI y
+ UBIFS_FS y
+ UBIFS_FS_XATTR y
+ UBIFS_FS_ADVANCED_COMPR y
+ UBIFS_FS_LZO y
+ UBIFS_FS_ZLIB y
+ UBIFS_FS_DEBUG n
+
+ # Kdb, for kernel troubles
+ KGDB y
+ KGDB_SERIAL_CONSOLE y
+ KGDB_KDB y
+ '';
+ kernelMakeFlags = [ "LOADADDR=0x0200000" ];
+ kernelTarget = "uImage";
+ kernelDTB = true; # Beyond 3.10
+ gcc = {
+ arch = "armv5te";
+ };
+ };
+
+ raspberrypi = {
+ name = "raspberrypi";
+ kernelMajor = "2.6";
+ kernelBaseConfig = "bcm2835_defconfig";
+ kernelDTB = true;
+ kernelArch = "arm";
+ kernelAutoModules = true;
+ kernelPreferBuiltin = true;
+ kernelExtraConfig = ''
+ # Disable OABI to have seccomp_filter (required for systemd)
+ # https://github.com/raspberrypi/firmware/issues/651
+ OABI_COMPAT n
+ '';
+ kernelTarget = "zImage";
+ gcc = {
+ arch = "armv6";
+ fpu = "vfp";
+ };
+ };
+
+ # Legacy attribute, for compatibility with existing configs only.
+ raspberrypi2 = armv7l-hf-multiplatform;
+
+ scaleway-c1 = armv7l-hf-multiplatform // {
+ gcc = {
+ cpu = "cortex-a9";
+ fpu = "vfpv3";
+ };
+ };
+
+ utilite = {
+ name = "utilite";
+ kernelMajor = "2.6";
+ kernelBaseConfig = "multi_v7_defconfig";
+ kernelArch = "arm";
+ kernelAutoModules = false;
+ kernelExtraConfig =
+ ''
+ # Ubi for the mtd
+ MTD_UBI y
+ UBIFS_FS y
+ UBIFS_FS_XATTR y
+ UBIFS_FS_ADVANCED_COMPR y
+ UBIFS_FS_LZO y
+ UBIFS_FS_ZLIB y
+ UBIFS_FS_DEBUG n
+ '';
+ kernelMakeFlags = [ "LOADADDR=0x10800000" ];
+ kernelTarget = "uImage";
+ kernelDTB = true;
+ gcc = {
+ cpu = "cortex-a9";
+ fpu = "neon";
+ };
+ };
+
+ guruplug = sheevaplug // {
+ # Define `CONFIG_MACH_GURUPLUG' (see
+ # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>)
+ # and other GuruPlug-specific things. Requires the `guruplug-defconfig'
+ # patch.
+
+ kernelBaseConfig = "guruplug_defconfig";
+ };
+
+ beaglebone = armv7l-hf-multiplatform // {
+ name = "beaglebone";
+ kernelBaseConfig = "bb.org_defconfig";
+ kernelAutoModules = false;
+ kernelExtraConfig = ""; # TBD kernel config
+ kernelTarget = "zImage";
+ };
+
+ # https://developer.android.com/ndk/guides/abis#v7a
+ armv7a-android = {
+ name = "armeabi-v7a";
+ gcc = {
+ arch = "armv7-a";
+ float-abi = "softfp";
+ fpu = "vfpv3-d16";
+ };
+ };
+
+ armv7l-hf-multiplatform = {
+ name = "armv7l-hf-multiplatform";
+ kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
+ kernelBaseConfig = "multi_v7_defconfig";
+ kernelArch = "arm";
+ kernelDTB = true;
+ kernelAutoModules = true;
+ kernelPreferBuiltin = true;
+ kernelTarget = "zImage";
+ kernelExtraConfig = ''
+ # Serial port for Raspberry Pi 3. Upstream forgot to add it to the ARMv7 defconfig.
+ SERIAL_8250_BCM2835AUX y
+ SERIAL_8250_EXTENDED y
+ SERIAL_8250_SHARE_IRQ y
+
+ # Fix broken sunxi-sid nvmem driver.
+ TI_CPTS y
+
+ # Hangs ODROID-XU4
+ ARM_BIG_LITTLE_CPUIDLE n
+
+ # Disable OABI to have seccomp_filter (required for systemd)
+ # https://github.com/raspberrypi/firmware/issues/651
+ OABI_COMPAT n
+ '';
+ gcc = {
+ # Some table about fpu flags:
+ # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png
+ # Cortex-A5: -mfpu=neon-fp16
+ # Cortex-A7 (rpi2): -mfpu=neon-vfpv4
+ # Cortex-A8 (beaglebone): -mfpu=neon
+ # Cortex-A9: -mfpu=neon-fp16
+ # Cortex-A15: -mfpu=neon-vfpv4
+
+ # More about FPU:
+ # https://wiki.debian.org/ArmHardFloatPort/VfpComparison
+
+ # vfpv3-d16 is what Debian uses and seems to be the best compromise: NEON is not supported in e.g. Scaleway or Tegra 2,
+ # and the above page suggests NEON is only an improvement with hand-written assembly.
+ arch = "armv7-a";
+ fpu = "vfpv3-d16";
+
+ # For Raspberry Pi the 2 the best would be:
+ # cpu = "cortex-a7";
+ # fpu = "neon-vfpv4";
+ };
+ };
+
+ aarch64-multiplatform = {
+ name = "aarch64-multiplatform";
+ kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
+ kernelBaseConfig = "defconfig";
+ kernelArch = "arm64";
+ kernelDTB = true;
+ kernelAutoModules = true;
+ kernelPreferBuiltin = true;
+ kernelExtraConfig = ''
+ # Raspberry Pi 3 stuff. Not needed for kernels >= 4.10.
+ ARCH_BCM2835 y
+ BCM2835_MBOX y
+ BCM2835_WDT y
+ RASPBERRYPI_FIRMWARE y
+ RASPBERRYPI_POWER y
+ SERIAL_8250_BCM2835AUX y
+ SERIAL_8250_EXTENDED y
+ SERIAL_8250_SHARE_IRQ y
+
+ # Cavium ThunderX stuff.
+ PCI_HOST_THUNDER_ECAM y
+
+ # Nvidia Tegra stuff.
+ PCI_TEGRA y
+
+ # The default (=y) forces us to have the XHCI firmware available in initrd,
+ # which our initrd builder can't currently do easily.
+ USB_XHCI_TEGRA m
+ '';
+ kernelTarget = "Image";
+ gcc = {
+ arch = "armv8-a";
+ };
+ };
+
+ ##
+ ## MIPS
+ ##
+
+ ben_nanonote = {
+ name = "ben_nanonote";
+ kernelMajor = "2.6";
+ kernelArch = "mips";
+ gcc = {
+ arch = "mips32";
+ float = "soft";
+ };
+ };
+
+ fuloong2f_n32 = {
+ name = "fuloong2f_n32";
+ kernelMajor = "2.6";
+ kernelBaseConfig = "lemote2f_defconfig";
+ kernelArch = "mips";
+ kernelAutoModules = false;
+ kernelExtraConfig = ''
+ MIGRATION n
+ COMPACTION n
+
+ # nixos mounts some cgroup
+ CGROUPS y
+
+ BLK_DEV_RAM y
+ BLK_DEV_INITRD y
+ BLK_DEV_CRYPTOLOOP m
+ BLK_DEV_DM m
+ DM_CRYPT m
+ MD y
+ REISERFS_FS m
+ EXT4_FS m
+ USB_STORAGE_CYPRESS_ATACB m
+
+ IP_PNP y
+ IP_PNP_DHCP y
+ IP_PNP_BOOTP y
+ NFS_FS y
+ ROOT_NFS y
+ TUN m
+ NFS_V4 y
+ NFS_V4_1 y
+ NFS_FSCACHE y
+ NFSD m
+ NFSD_V2_ACL y
+ NFSD_V3 y
+ NFSD_V3_ACL y
+ NFSD_V4 y
+
+ # Fail to build
+ DRM n
+ SCSI_ADVANSYS n
+ USB_ISP1362_HCD n
+ SND_SOC n
+ SND_ALI5451 n
+ FB_SAVAGE n
+ SCSI_NSP32 n
+ ATA_SFF n
+ SUNGEM n
+ IRDA n
+ ATM_HE n
+ SCSI_ACARD n
+ BLK_DEV_CMD640_ENHANCED n
+
+ FUSE_FS m
+
+ # Needed for udev >= 150
+ SYSFS_DEPRECATED_V2 n
+
+ VGA_CONSOLE n
+ VT_HW_CONSOLE_BINDING y
+ SERIAL_8250_CONSOLE y
+ FRAMEBUFFER_CONSOLE y
+ EXT2_FS y
+ EXT3_FS y
+ REISERFS_FS y
+ MAGIC_SYSRQ y
+
+ # The kernel doesn't boot at all, with FTRACE
+ FTRACE n
+ '';
+ kernelTarget = "vmlinux";
+ gcc = {
+ arch = "loongson2f";
+ float = "hard";
+ abi = "n32";
+ };
+ };
+
+ ##
+ ## Other
+ ##
+
+ riscv-multiplatform = bits: {
+ name = "riscv-multiplatform";
+ kernelArch = "riscv";
+ bfdEmulation = "elf${bits}lriscv";
+ kernelTarget = "vmlinux";
+ kernelAutoModules = true;
+ kernelBaseConfig = "defconfig";
+ kernelExtraConfig = ''
+ FTRACE n
+ SERIAL_OF_PLATFORM y
+ '';
+ };
+
+ selectBySystem = system: {
+ i486-linux = pc32;
+ i586-linux = pc32;
+ i686-linux = pc32;
+ x86_64-linux = pc64;
+ armv5tel-linux = sheevaplug;
+ armv6l-linux = raspberrypi;
+ armv7a-linux = armv7l-hf-multiplatform;
+ armv7l-linux = armv7l-hf-multiplatform;
+ aarch64-linux = aarch64-multiplatform;
+ mipsel-linux = fuloong2f_n32;
+ powerpc64le-linux = powernv;
+ }.${system} or pcBase;
+}