summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/customisation.nix27
-rw-r--r--lib/default.nix6
-rw-r--r--lib/fixed-points.nix11
-rw-r--r--lib/licenses.nix5
-rw-r--r--lib/lists.nix8
-rw-r--r--lib/sources.nix2
-rw-r--r--lib/strings.nix8
-rw-r--r--lib/systems/doubles.nix5
-rw-r--r--lib/systems/examples.nix16
-rw-r--r--lib/systems/inspect.nix2
-rw-r--r--lib/systems/parse.nix35
-rw-r--r--lib/systems/platforms.nix14
-rw-r--r--lib/tests/misc.nix20
-rw-r--r--lib/tests/systems.nix6
14 files changed, 135 insertions, 30 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index dc5dd7691976..37a7951896b0 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -217,4 +217,31 @@ rec {
};
in self;
+ /* Like the above, but aims to support cross compilation. It's still ugly, but
+ hopefully it helps a little bit. */
+ makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: f:
+ let
+ spliced = splicePackages {
+ pkgsBuildBuild = otherSplices.selfBuildBuild;
+ pkgsBuildHost = otherSplices.selfBuildHost;
+ pkgsBuildTarget = otherSplices.selfBuildTarget;
+ pkgsHostHost = otherSplices.selfHostHost;
+ pkgsHostTarget = self; # Not `otherSplices.selfHostTarget`;
+ pkgsTargetTarget = otherSplices.selfTargetTarget;
+ } // keep self;
+ self = f self // {
+ newScope = scope: newScope (spliced // scope);
+ callPackage = newScope spliced; # == self.newScope {};
+ # N.B. the other stages of the package set spliced in are *not*
+ # overridden.
+ overrideScope = g: makeScopeWithSplicing
+ splicePackages
+ newScope
+ otherSplices
+ keep
+ (lib.fixedPoints.extends g f);
+ packages = f;
+ };
+ in self;
+
}
diff --git a/lib/default.nix b/lib/default.nix
index d2239d26eadf..f985266ed938 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -5,7 +5,7 @@
*/
let
- inherit (import ./fixed-points.nix {}) makeExtensible;
+ inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
lib = makeExtensible (self: let
callLibs = file: import file { lib = self; };
@@ -69,7 +69,7 @@ let
importJSON importTOML warn info showWarnings nixpkgsVersion version mod compare
splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
- makeExtensible makeExtensibleWithCustomName;
+ composeManyExtensions makeExtensible makeExtensibleWithCustomName;
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
@@ -101,7 +101,7 @@ let
noDepEntry fullDepEntry packEntry stringAfter;
inherit (self.customisation) overrideDerivation makeOverridable
callPackageWith callPackagesWith extendDerivation hydraJob
- makeScope;
+ makeScope makeScopeWithSplicing;
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
hiPrioSet;
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index 968930526a63..f998bc74e1db 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -1,4 +1,4 @@
-{ ... }:
+{ lib, ... }:
rec {
# Compute the fixed point of the given function `f`, which is usually an
# attribute set that expects its final, non-recursive representation as an
@@ -77,6 +77,15 @@ rec {
super' = super // fApplied;
in fApplied // g self super';
+ # Compose several extending functions of the type expected by 'extends' into
+ # one where changes made in preceding functions are made available to
+ # subsequent ones.
+ #
+ # composeManyExtensions : [packageSet -> packageSet -> packageSet] -> packageSet -> packageSet -> packageSet
+ # ^final ^prev ^overrides ^final ^prev ^overrides
+ composeManyExtensions =
+ lib.foldr (x: y: composeExtensions x y) (self: super: {});
+
# Create an overridable, recursive attribute set. For example:
#
# nix-repl> obj = makeExtensible (self: { })
diff --git a/lib/licenses.nix b/lib/licenses.nix
index a704a6884c7d..850de29e7d13 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -392,6 +392,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "Historic Permission Notice and Disclaimer";
};
+ hpndSellVariant = spdx {
+ fullName = "Historical Permission Notice and Disclaimer - sell variant";
+ spdxId = "HPND-sell-variant";
+ };
+
# Intel's license, seems free
iasl = {
fullName = "iASL";
diff --git a/lib/lists.nix b/lib/lists.nix
index 6c97e0686aa8..06cee2eb112a 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -640,13 +640,7 @@ rec {
unique [ 3 2 3 4 ]
=> [ 3 2 4 ]
*/
- unique = list:
- if list == [] then
- []
- else
- let
- x = head list;
- in [x] ++ unique (remove x list);
+ unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
/* Intersects list 'e' and another list. O(nm) complexity.
diff --git a/lib/sources.nix b/lib/sources.nix
index 702a0ef88921..1a3afcae67da 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -6,6 +6,7 @@ let
hasContext
match
readDir
+ split
storeDir
tryEval
;
@@ -15,7 +16,6 @@ let
isString
pathExists
readFile
- split
;
in
rec {
diff --git a/lib/strings.nix b/lib/strings.nix
index f62ff6679ef5..fbb48dec92af 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -561,7 +561,9 @@ rec {
enableFeature false "shared"
=> "--disable-shared"
*/
- enableFeature = enable: feat: "--${if enable then "enable" else "disable"}-${feat}";
+ enableFeature = enable: feat:
+ assert isString feat; # e.g. passing openssl instead of "openssl"
+ "--${if enable then "enable" else "disable"}-${feat}";
/* Create an --{enable-<feat>=<value>,disable-<feat>} string that can be passed to
standard GNU Autoconf scripts.
@@ -583,7 +585,9 @@ rec {
withFeature false "shared"
=> "--without-shared"
*/
- withFeature = with_: feat: "--${if with_ then "with" else "without"}-${feat}";
+ withFeature = with_: feat:
+ assert isString feat; # e.g. passing openssl instead of "openssl"
+ "--${if with_ then "with" else "without"}-${feat}";
/* Create an --{with-<feat>=<value>,without-<feat>} string that can be passed to
standard GNU Autoconf scripts.
diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix
index 517a7296afd2..b0bc7dd1188a 100644
--- a/lib/systems/doubles.nix
+++ b/lib/systems/doubles.nix
@@ -35,6 +35,9 @@ let
"msp430-none"
"riscv64-none" "riscv32-none"
"vc4-none"
+ "or1k-none"
+
+ "mmix-mmixware"
"js-ghcjs"
@@ -56,8 +59,10 @@ in {
i686 = filterDoubles predicates.isi686;
x86_64 = filterDoubles predicates.isx86_64;
mips = filterDoubles predicates.isMips;
+ mmix = filterDoubles predicates.isMmix;
riscv = filterDoubles predicates.isRiscV;
vc4 = filterDoubles predicates.isVc4;
+ or1k = filterDoubles predicates.isOr1k;
js = filterDoubles predicates.isJavaScript;
bigEndian = filterDoubles predicates.isBigEndian;
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 87c05a0b0524..3bbe61ed33a5 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -34,6 +34,11 @@ rec {
platform = platforms.raspberrypi;
};
+ remarkable1 = {
+ config = "armv7l-unknown-linux-gnueabihf";
+ platform = platforms.zero-gravitas;
+ };
+
armv7l-hf-multiplatform = {
config = "armv7l-unknown-linux-gnueabihf";
platform = platforms.armv7l-hf-multiplatform;
@@ -109,6 +114,11 @@ rec {
platform = platforms.riscv-multiplatform "32";
};
+ mmix = {
+ config = "mmix-unknown-mmixware";
+ libc = "newlib";
+ };
+
msp430 = {
config = "msp430-elf";
libc = "newlib";
@@ -124,6 +134,12 @@ rec {
platform = {};
};
+ or1k = {
+ config = "or1k-elf";
+ libc = "newlib";
+ platform = {};
+ };
+
arm-embedded = {
config = "arm-none-eabi";
libc = "newlib";
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 8fa630572509..d2b7271210cd 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -17,6 +17,7 @@ rec {
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
isMips = { cpu = { family = "mips"; }; };
+ isMmix = { cpu = { family = "mmix"; }; };
isRiscV = { cpu = { family = "riscv"; }; };
isSparc = { cpu = { family = "sparc"; }; };
isWasm = { cpu = { family = "wasm"; }; };
@@ -24,6 +25,7 @@ rec {
isVc4 = { cpu = { family = "vc4"; }; };
isAvr = { cpu = { family = "avr"; }; };
isAlpha = { cpu = { family = "alpha"; }; };
+ isOr1k = { cpu = { family = "or1k"; }; };
isJavaScript = { cpu = cpuTypes.js; };
is32bit = { cpu = { bits = 32; }; };
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 6bd44a007466..a06ac0d11f74 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -93,6 +93,8 @@ rec {
mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; };
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
+ mmix = { bits = 64; significantByte = bigEndian; family = "mmix"; };
+
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
@@ -114,6 +116,8 @@ rec {
vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; };
+ or1k = { bits = 32; significantByte = bigEndian; family = "or1k"; };
+
js = { bits = 32; significantByte = littleEndian; family = "js"; };
};
@@ -268,19 +272,20 @@ rec {
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 = { }; };
- redox = { execFormat = elf; families = { }; };
- windows = { execFormat = pe; families = { }; };
- ghcjs = { execFormat = unknown; families = { }; };
- genode = { execFormat = elf; families = { }; };
+ 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 = { }; };
+ redox = { execFormat = elf; families = { }; };
+ windows = { execFormat = pe; families = { }; };
+ ghcjs = { execFormat = unknown; families = { }; };
+ genode = { execFormat = elf; families = { }; };
+ mmixware = { execFormat = unknown; families = { }; };
} // { # aliases
# 'darwin' is the kernel for all of them. We choose macOS by default.
darwin = kernels.macos;
@@ -382,7 +387,7 @@ rec {
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!
+ "3" = # Awkward 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")
@@ -393,6 +398,8 @@ rec {
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; }
else if (elemAt l 2 == "redox")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; }
+ else if (elemAt l 2 == "mmixware")
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "mmixware"; }
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"])
diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix
index ab3cf1d54301..42d9809fd7d0 100644
--- a/lib/systems/platforms.nix
+++ b/lib/systems/platforms.nix
@@ -203,6 +203,20 @@ rec {
# Legacy attribute, for compatibility with existing configs only.
raspberrypi2 = armv7l-hf-multiplatform;
+ zero-gravitas = {
+ name = "zero-gravitas";
+ kernelBaseConfig = "zero-gravitas_defconfig";
+ kernelArch = "arm";
+ # kernelTarget verified by checking /boot on reMarkable 1 device
+ kernelTarget = "zImage";
+ kernelAutoModules = false;
+ kernelDTB = true;
+ gcc = {
+ fpu = "neon";
+ cpu = "cortex-a9";
+ };
+ };
+
scaleway-c1 = armv7l-hf-multiplatform // {
gcc = {
cpu = "cortex-a9";
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 6175f15819a7..35a5801c724f 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -87,6 +87,26 @@ runTests {
expected = true;
};
+ testComposeManyExtensions0 = {
+ expr = let obj = makeExtensible (self: { foo = true; });
+ emptyComposition = composeManyExtensions [];
+ composed = obj.extend emptyComposition;
+ in composed.foo;
+ expected = true;
+ };
+
+ testComposeManyExtensions =
+ let f = self: super: { bar = false; baz = true; };
+ g = self: super: { bar = super.baz or false; };
+ h = self: super: { qux = super.bar or false; };
+ obj = makeExtensible (self: { foo = self.qux; });
+ in {
+ expr = let composition = composeManyExtensions [f g h];
+ composed = obj.extend composition;
+ in composed.foo;
+ expected = (obj.extend (composeExtensions f (composeExtensions g h))).foo;
+ };
+
testBitAnd = {
expr = (bitAnd 3 10);
expected = 2;
diff --git a/lib/tests/systems.nix b/lib/tests/systems.nix
index f691b2da3165..eed7ee725bc4 100644
--- a/lib/tests/systems.nix
+++ b/lib/tests/systems.nix
@@ -11,12 +11,14 @@ let
expr = lib.sort lib.lessThan x;
expected = lib.sort lib.lessThan y;
};
-in with lib.systems.doubles; lib.runTests {
- testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js ++ genode ++ redox);
+in
+with lib.systems.doubles; lib.runTests {
+ testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ mmix ++ js ++ genode ++ redox);
testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv6l-none" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ];
testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-genode" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" "i686-none" "i686-darwin" ];
testmips = mseteq mips [ "mipsel-linux" ];
+ testmmix = mseteq mmix [ "mmix-mmixware" ];
testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-genode" "x86_64-redox" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" "x86_64-none" ];
testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ];