Merge remote-tracking branch 'upstream/master' into ghcjs-cross-without-cc
This commit is contained in:
@@ -354,7 +354,7 @@ rec {
|
||||
=> { a = ["x" "y"]; b = ["z"] }
|
||||
*/
|
||||
zipAttrsWith = f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets;
|
||||
/* Like `zipAttrsWith' with `(name: values: value)' as the function.
|
||||
/* Like `zipAttrsWith' with `(name: values: values)' as the function.
|
||||
|
||||
Example:
|
||||
zipAttrs [{a = "x";} {a = "y"; b = "z";}]
|
||||
|
||||
@@ -66,22 +66,31 @@ rec {
|
||||
*/
|
||||
makeOverridable = f: origArgs:
|
||||
let
|
||||
ff = f origArgs;
|
||||
result = f origArgs;
|
||||
|
||||
# Creates a functor with the same arguments as f
|
||||
copyArgs = g: lib.setFunctionArgs g (lib.functionArgs f);
|
||||
# Changes the original arguments with (potentially a function that returns) a set of new attributes
|
||||
overrideWith = newArgs: origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs);
|
||||
|
||||
# Re-call the function but with different arguments
|
||||
overrideArgs = copyArgs (newArgs: makeOverridable f (overrideWith newArgs));
|
||||
# Change the result of the function call by applying g to it
|
||||
overrideResult = g: makeOverridable (copyArgs (args: g (f args))) origArgs;
|
||||
in
|
||||
if builtins.isAttrs ff then (ff // {
|
||||
override = newArgs: makeOverridable f (overrideWith newArgs);
|
||||
overrideDerivation = fdrv:
|
||||
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs;
|
||||
${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
|
||||
makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
|
||||
})
|
||||
else if lib.isFunction ff then {
|
||||
override = newArgs: makeOverridable f (overrideWith newArgs);
|
||||
__functor = self: ff;
|
||||
overrideDerivation = throw "overrideDerivation not yet supported for functors";
|
||||
}
|
||||
else ff;
|
||||
if builtins.isAttrs result then
|
||||
result // {
|
||||
override = overrideArgs;
|
||||
overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
|
||||
${if result ? overrideAttrs then "overrideAttrs" else null} = fdrv:
|
||||
overrideResult (x: x.overrideAttrs fdrv);
|
||||
}
|
||||
else if lib.isFunction result then
|
||||
# Transform the result into a functor while propagating its arguments
|
||||
lib.setFunctionArgs result (lib.functionArgs result) // {
|
||||
override = overrideArgs;
|
||||
}
|
||||
else result;
|
||||
|
||||
|
||||
/* Call the package function in the file `fn' with the required
|
||||
|
||||
@@ -57,8 +57,8 @@ let
|
||||
hasAttr head isAttrs isBool isInt isList isString length
|
||||
lessThan listToAttrs pathExists readFile replaceStrings seq
|
||||
stringLength sub substring tail;
|
||||
inherit (trivial) id const concat or and bitAnd bitOr bitXor bitNot
|
||||
boolToString mergeAttrs flip mapNullable inNixShell min max
|
||||
inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
|
||||
bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
|
||||
importJSON warn info showWarnings nixpkgsVersion version mod compare
|
||||
splitByAndCompare functionArgs setFunctionArgs isFunction;
|
||||
inherit (fixedPoints) fix fix' converge extends composeExtensions
|
||||
@@ -135,5 +135,7 @@ let
|
||||
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
||||
fakeSha256 fakeSha512
|
||||
nixType imap;
|
||||
inherit (versions)
|
||||
splitVersion;
|
||||
});
|
||||
in lib
|
||||
|
||||
@@ -218,9 +218,9 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
||||
fullName = "Common Public License 1.0";
|
||||
};
|
||||
|
||||
curl = {
|
||||
fullName = "MIT/X11 derivate";
|
||||
url = "https://curl.haxx.se/docs/copyright.html";
|
||||
curl = spdx {
|
||||
spdxId = "curl";
|
||||
fullName = "curl License";
|
||||
};
|
||||
|
||||
doc = spdx {
|
||||
@@ -613,6 +613,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
||||
url = https://enterprise.dejacode.com/licenses/public/purdue-bsd;
|
||||
};
|
||||
|
||||
qhull = spdx {
|
||||
spdxId = "Qhull";
|
||||
fullName = "Qhull License";
|
||||
};
|
||||
|
||||
qpl = spdx {
|
||||
spdxId = "QPL-1.0";
|
||||
fullName = "Q Public License 1.0";
|
||||
|
||||
@@ -326,6 +326,8 @@ rec {
|
||||
|
||||
# The value with a check that it is defined
|
||||
valueDefined = if res.isDefined then res.mergedValue else
|
||||
# (nixos-option detects this specific error message and gives it special
|
||||
# handling. If changed here, please change it there too.)
|
||||
throw "The option `${showOption loc}' is used but not defined.";
|
||||
|
||||
# Apply the 'apply' function to the merged value. This allows options to
|
||||
@@ -591,12 +593,16 @@ rec {
|
||||
{ options, ... }:
|
||||
{ options = setAttrByPath optionName (mkOption {
|
||||
visible = false;
|
||||
apply = x: throw "The option `${showOption optionName}' can no longer be used since it's been removed. ${replacementInstructions}";
|
||||
});
|
||||
config.warnings =
|
||||
let opt = getAttrFromPath optionName options; in
|
||||
optional opt.isDefined ''
|
||||
config.assertions =
|
||||
let opt = getAttrFromPath optionName options; in [{
|
||||
assertion = !opt.isDefined;
|
||||
message = ''
|
||||
The option definition `${showOption optionName}' in ${showFiles opt.files} no longer has any effect; please remove it.
|
||||
${replacementInstructions}'';
|
||||
${replacementInstructions}
|
||||
'';
|
||||
}];
|
||||
};
|
||||
|
||||
/* Return a module that causes a warning to be shown if the
|
||||
|
||||
@@ -37,6 +37,7 @@ rec {
|
||||
else if final.isAndroid then "bionic"
|
||||
else if final.isLinux /* default */ then "glibc"
|
||||
else if final.isMsp430 then "newlib"
|
||||
else if final.isVc4 then "newlib"
|
||||
else if final.isAvr then "avrlibc"
|
||||
else if final.isNetBSD then "nblibc"
|
||||
# TODO(@Ericson2314) think more about other operating systems
|
||||
@@ -79,6 +80,7 @@ rec {
|
||||
else if final.isAarch64 then "arm64"
|
||||
else if final.isx86_32 then "x86"
|
||||
else if final.isx86_64 then "ia64"
|
||||
else if final.isMips then "mips"
|
||||
else final.parsed.cpu.name;
|
||||
|
||||
qemuArch =
|
||||
|
||||
@@ -26,7 +26,7 @@ let
|
||||
|
||||
"riscv32-linux" "riscv64-linux"
|
||||
|
||||
"aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none"
|
||||
"aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none"
|
||||
|
||||
"js-ghcjs"
|
||||
];
|
||||
@@ -47,6 +47,7 @@ in {
|
||||
x86_64 = filterDoubles predicates.isx86_64;
|
||||
mips = filterDoubles predicates.isMips;
|
||||
riscv = filterDoubles predicates.isRiscV;
|
||||
vc4 = filterDoubles predicates.isVc4;
|
||||
|
||||
cygwin = filterDoubles predicates.isCygwin;
|
||||
darwin = filterDoubles predicates.isDarwin;
|
||||
|
||||
@@ -118,6 +118,12 @@ rec {
|
||||
config = "avr";
|
||||
};
|
||||
|
||||
vc4 = {
|
||||
config = "vc4-elf";
|
||||
libc = "newlib";
|
||||
platform = {};
|
||||
};
|
||||
|
||||
arm-embedded = {
|
||||
config = "arm-none-eabi";
|
||||
libc = "newlib";
|
||||
|
||||
@@ -21,6 +21,7 @@ rec {
|
||||
isSparc = { cpu = { family = "sparc"; }; };
|
||||
isWasm = { cpu = { family = "wasm"; }; };
|
||||
isMsp430 = { cpu = { family = "msp430"; }; };
|
||||
isVc4 = { cpu = { family = "vc4"; }; };
|
||||
isAvr = { cpu = { family = "avr"; }; };
|
||||
isAlpha = { cpu = { family = "alpha"; }; };
|
||||
isJavaScript = { cpu = cpuTypes.js; };
|
||||
|
||||
@@ -112,6 +112,8 @@ rec {
|
||||
msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; };
|
||||
avr = { bits = 8; family = "avr"; };
|
||||
|
||||
vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; };
|
||||
|
||||
js = { bits = 32; significantByte = littleEndian; family = "js"; };
|
||||
};
|
||||
|
||||
@@ -330,6 +332,7 @@ rec {
|
||||
}
|
||||
];
|
||||
};
|
||||
gnuabi64 = { abi = "64"; };
|
||||
|
||||
musleabi = { float = "soft"; };
|
||||
musleabihf = { float = "hard"; };
|
||||
|
||||
@@ -18,6 +18,31 @@ runTests {
|
||||
expected = 2;
|
||||
};
|
||||
|
||||
testPipe = {
|
||||
expr = pipe 2 [
|
||||
(x: x + 2) # 2 + 2 = 4
|
||||
(x: x * 2) # 4 * 2 = 8
|
||||
];
|
||||
expected = 8;
|
||||
};
|
||||
|
||||
testPipeEmpty = {
|
||||
expr = pipe 2 [];
|
||||
expected = 2;
|
||||
};
|
||||
|
||||
testPipeStrings = {
|
||||
expr = pipe [ 3 4 ] [
|
||||
(map toString)
|
||||
(map (s: s + "\n"))
|
||||
concatStrings
|
||||
];
|
||||
expected = ''
|
||||
3
|
||||
4
|
||||
'';
|
||||
};
|
||||
|
||||
/*
|
||||
testOr = {
|
||||
expr = or true false;
|
||||
@@ -102,6 +127,21 @@ runTests {
|
||||
expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ];
|
||||
};
|
||||
|
||||
testSplitVersionSingle = {
|
||||
expr = versions.splitVersion "1";
|
||||
expected = [ "1" ];
|
||||
};
|
||||
|
||||
testSplitVersionDouble = {
|
||||
expr = versions.splitVersion "1.2";
|
||||
expected = [ "1" "2" ];
|
||||
};
|
||||
|
||||
testSplitVersionTriple = {
|
||||
expr = versions.splitVersion "1.2.3";
|
||||
expected = [ "1" "2" "3" ];
|
||||
};
|
||||
|
||||
testIsStorePath = {
|
||||
expr =
|
||||
let goodPath =
|
||||
|
||||
@@ -29,6 +29,43 @@ rec {
|
||||
# Value to ignore
|
||||
y: x;
|
||||
|
||||
/* Pipes a value through a list of functions, left to right.
|
||||
|
||||
Type: pipe :: a -> [<functions>] -> <return type of last function>
|
||||
Example:
|
||||
pipe 2 [
|
||||
(x: x + 2) # 2 + 2 = 4
|
||||
(x: x * 2) # 4 * 2 = 8
|
||||
]
|
||||
=> 8
|
||||
|
||||
# ideal to do text transformations
|
||||
pipe [ "a/b" "a/c" ] [
|
||||
|
||||
# create the cp command
|
||||
(map (file: ''cp "${src}/${file}" $out\n''))
|
||||
|
||||
# concatenate all commands into one string
|
||||
lib.concatStrings
|
||||
|
||||
# make that string into a nix derivation
|
||||
(pkgs.runCommand "copy-to-out" {})
|
||||
|
||||
]
|
||||
=> <drv which copies all files to $out>
|
||||
|
||||
The output type of each function has to be the input type
|
||||
of the next function, and the last function returns the
|
||||
final value.
|
||||
*/
|
||||
pipe = val: functions:
|
||||
let reverseApply = x: f: f x;
|
||||
in builtins.foldl' reverseApply val functions;
|
||||
/* note please don’t add a function like `compose = flip pipe`.
|
||||
This would confuse users, because the order of the functions
|
||||
in the list is not clear. With pipe, it’s obvious that it
|
||||
goes first-to-last. With `compose`, not so much.
|
||||
*/
|
||||
|
||||
## Named versions corresponding to some builtin operators.
|
||||
|
||||
@@ -134,7 +171,7 @@ rec {
|
||||
On each release the first letter is bumped and a new animal is chosen
|
||||
starting with that new letter.
|
||||
*/
|
||||
codeName = "Loris";
|
||||
codeName = "Markhor";
|
||||
|
||||
/* Returns the current nixpkgs version suffix as string. */
|
||||
versionSuffix =
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
/* Version string functions. */
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
rec {
|
||||
|
||||
/* Break a version string into its component parts.
|
||||
|
||||
Example:
|
||||
splitVersion "1.2.3"
|
||||
=> ["1" "2" "3"]
|
||||
*/
|
||||
splitVersion = builtins.splitVersion or (lib.splitString ".");
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
/* Get the major version string from a string.
|
||||
|
||||
Example:
|
||||
|
||||
Reference in New Issue
Block a user