Merge branch 'master' into add-newer-xcode-hashes
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,9 +14,25 @@
|
||||
*/
|
||||
{ lib }:
|
||||
let
|
||||
inherit (builtins) trace isAttrs isList isInt
|
||||
head substring attrNames;
|
||||
inherit (lib) id elem isFunction;
|
||||
inherit (lib)
|
||||
isInt
|
||||
attrNames
|
||||
isList
|
||||
isAttrs
|
||||
substring
|
||||
addErrorContext
|
||||
attrValues
|
||||
concatLists
|
||||
concatStringsSep
|
||||
const
|
||||
elem
|
||||
generators
|
||||
head
|
||||
id
|
||||
isDerivation
|
||||
isFunction
|
||||
mapAttrs
|
||||
trace;
|
||||
in
|
||||
|
||||
rec {
|
||||
@@ -94,7 +110,7 @@ rec {
|
||||
trace: { a = { b = {…}; }; }
|
||||
=> null
|
||||
*/
|
||||
traceSeqN = depth: x: y: with lib;
|
||||
traceSeqN = depth: x: y:
|
||||
let snip = v: if isList v then noQuotes "[…]" v
|
||||
else if isAttrs v then noQuotes "{…}" v
|
||||
else v;
|
||||
@@ -149,7 +165,7 @@ rec {
|
||||
*/
|
||||
runTests =
|
||||
# Tests to run
|
||||
tests: lib.concatLists (lib.attrValues (lib.mapAttrs (name: test:
|
||||
tests: concatLists (attrValues (mapAttrs (name: test:
|
||||
let testsToRun = if tests ? tests then tests.tests else [];
|
||||
in if (substring 0 4 name == "test" || elem name testsToRun)
|
||||
&& ((testsToRun == []) || elem name tests.tests)
|
||||
@@ -176,9 +192,9 @@ rec {
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use more specific concatenation "
|
||||
+ "for your uses (`lib.concat(Map)StringsSep`)." )
|
||||
(lib.concatStringsSep "; " (map (x: "${x}=") (attrNames a)));
|
||||
(concatStringsSep "; " (map (x: "${x}=") (attrNames a)));
|
||||
|
||||
showVal = with lib;
|
||||
showVal =
|
||||
trace ( "Warning: `showVal` is deprecated "
|
||||
+ "and will be removed in the next release, "
|
||||
+ "please use `traceSeqN`" )
|
||||
@@ -226,7 +242,7 @@ rec {
|
||||
trace ( "Warning: `addErrorContextToAttrs` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use `builtins.addErrorContext` directly." )
|
||||
(lib.mapAttrs (a: v: lib.addErrorContext "while evaluating ${a}" v) attrs);
|
||||
(mapAttrs (a: v: addErrorContext "while evaluating ${a}" v) attrs);
|
||||
|
||||
# example: (traceCallXml "myfun" id 3) will output something like
|
||||
# calling myfun arg 1: 3 result: 3
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*/
|
||||
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; };
|
||||
in with self; {
|
||||
in {
|
||||
|
||||
# often used, or depending on very little
|
||||
trivial = callLibs ./trivial.nix;
|
||||
@@ -54,7 +54,7 @@ let
|
||||
filesystem = callLibs ./filesystem.nix;
|
||||
|
||||
# back-compat aliases
|
||||
platforms = systems.doubles;
|
||||
platforms = self.systems.doubles;
|
||||
|
||||
# linux kernel configuration
|
||||
kernel = callLibs ./kernel.nix;
|
||||
@@ -63,14 +63,14 @@ let
|
||||
deepSeq elem elemAt filter genericClosure genList getAttr
|
||||
hasAttr head isAttrs isBool isInt isList isString length
|
||||
lessThan listToAttrs pathExists readFile replaceStrings seq
|
||||
stringLength sub substring tail;
|
||||
inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
|
||||
bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
|
||||
stringLength sub substring tail trace;
|
||||
inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor
|
||||
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
||||
importJSON importTOML warn info showWarnings nixpkgsVersion version mod compare
|
||||
splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
|
||||
inherit (fixedPoints) fix fix' converge extends composeExtensions
|
||||
makeExtensible makeExtensibleWithCustomName;
|
||||
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
||||
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
||||
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
||||
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
||||
mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
|
||||
@@ -79,13 +79,13 @@ let
|
||||
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
||||
getLib getDev getMan chooseDevOutputs zipWithNames zip
|
||||
recurseIntoAttrs dontRecurseIntoAttrs;
|
||||
inherit (lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
||||
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
||||
concatMap flatten remove findSingle findFirst any all count
|
||||
optional optionals toList range partition zipListsWith zipLists
|
||||
reverseList listDfs toposort sort naturalSort compareLists take
|
||||
drop sublist last init crossLists unique intersectLists
|
||||
subtractLists mutuallyExclusive groupBy groupBy';
|
||||
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
||||
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
||||
intersperse concatStringsSep concatMapStringsSep
|
||||
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
||||
makeLibraryPath makeBinPath optionalString
|
||||
@@ -97,19 +97,19 @@ let
|
||||
nameFromURL enableFeature enableFeatureAs withFeature
|
||||
withFeatureAs fixedWidthString fixedWidthNumber isStorePath
|
||||
toInt readPathsFromFile fileContents;
|
||||
inherit (stringsWithDeps) textClosureList textClosureMap
|
||||
inherit (self.stringsWithDeps) textClosureList textClosureMap
|
||||
noDepEntry fullDepEntry packEntry stringAfter;
|
||||
inherit (customisation) overrideDerivation makeOverridable
|
||||
inherit (self.customisation) overrideDerivation makeOverridable
|
||||
callPackageWith callPackagesWith extendDerivation hydraJob
|
||||
makeScope;
|
||||
inherit (meta) addMetaAttrs dontDistribute setName updateName
|
||||
makeScope makeScopeWithSplicing;
|
||||
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
||||
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
||||
hiPrioSet;
|
||||
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
||||
inherit (self.sources) pathType pathIsDirectory cleanSourceFilter
|
||||
cleanSource sourceByRegex sourceFilesBySuffices
|
||||
commitIdFromGitRepo cleanSourceWith pathHasContext
|
||||
canCleanSource pathIsRegularFile pathIsGitRepo;
|
||||
inherit (modules) evalModules unifyModuleSyntax
|
||||
inherit (self.modules) evalModules unifyModuleSyntax
|
||||
applyIfFunction mergeModules
|
||||
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
||||
pushDownProperties dischargeProperties filterOverrides
|
||||
@@ -119,21 +119,21 @@ let
|
||||
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
||||
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
||||
mkAliasOptionModule doRename;
|
||||
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
||||
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
||||
scrubOptionValue literalExample showOption showFiles
|
||||
unknownModule mkOption;
|
||||
inherit (types) isType setType defaultTypeMerge defaultFunctor
|
||||
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
||||
isOptionType mkOptionType;
|
||||
inherit (asserts)
|
||||
inherit (self.asserts)
|
||||
assertMsg assertOneOf;
|
||||
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
||||
inherit (self.debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
||||
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
||||
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
|
||||
traceShowValMarked showVal traceCall traceCall2 traceCall3
|
||||
traceValIfNot runTests testAllTrue traceCallXml attrNamesToStr;
|
||||
inherit (misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
||||
inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
||||
maybeAttrNullable maybeAttr ifEnable checkFlag getValue
|
||||
checkReqs uniqList uniqListExt condConcat lazyGenericClosure
|
||||
innerModifySumArgs modifySumArgs innerClosePropagation
|
||||
@@ -143,7 +143,7 @@ let
|
||||
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
||||
fakeHash fakeSha256 fakeSha512
|
||||
nixType imap;
|
||||
inherit (versions)
|
||||
inherit (self.versions)
|
||||
splitVersion;
|
||||
});
|
||||
in lib
|
||||
|
||||
@@ -42,4 +42,16 @@
|
||||
type = (builtins.readDir parent).${base} or null;
|
||||
in file == /. || type == "directory";
|
||||
in go (if isDir then file else parent);
|
||||
|
||||
|
||||
# listFilesRecursive: Path -> [ Path ]
|
||||
#
|
||||
# Given a directory, return a flattened list of all files within it recursively.
|
||||
listFilesRecursive = dir: lib.flatten (lib.mapAttrsToList (name: type:
|
||||
if type == "directory" then
|
||||
lib.filesystem.listFilesRecursive (dir + "/${name}")
|
||||
else
|
||||
dir + "/${name}"
|
||||
) (builtins.readDir dir));
|
||||
|
||||
}
|
||||
|
||||
@@ -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: { })
|
||||
|
||||
@@ -18,6 +18,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
||||
fullName = "Abstyles License";
|
||||
};
|
||||
|
||||
afl20 = spdx {
|
||||
spdxId = "AFL-2.0";
|
||||
fullName = "Academic Free License v2.0";
|
||||
};
|
||||
|
||||
afl21 = spdx {
|
||||
spdxId = "AFL-2.1";
|
||||
fullName = "Academic Free License v2.1";
|
||||
@@ -392,6 +397,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";
|
||||
@@ -613,6 +623,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
||||
fullName = "Open Software License 3.0";
|
||||
};
|
||||
|
||||
parity70 = spdx {
|
||||
spdxId = "Parity-7.0.0";
|
||||
fullName = "Parity Public License 7.0.0";
|
||||
url = "https://paritylicense.com/versions/7.0.0.html";
|
||||
};
|
||||
|
||||
php301 = spdx {
|
||||
spdxId = "PHP-3.01";
|
||||
fullName = "PHP License v3.01";
|
||||
@@ -801,14 +817,54 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
||||
};
|
||||
} // {
|
||||
# TODO: remove legacy aliases
|
||||
agpl3 = lib.licenses.agpl3Only;
|
||||
fdl11 = lib.licenses.fdl11Only;
|
||||
fdl12 = lib.licenses.fdl12Only;
|
||||
fdl13 = lib.licenses.fdl13Only;
|
||||
gpl1 = lib.licenses.gpl1Only;
|
||||
gpl2 = lib.licenses.gpl2Only;
|
||||
gpl3 = lib.licenses.gpl3Only;
|
||||
lgpl2 = lib.licenses.lgpl2Only;
|
||||
lgpl21 = lib.licenses.lgpl21Only;
|
||||
lgpl3 = lib.licenses.lgpl3Only;
|
||||
agpl3 = spdx {
|
||||
spdxId = "AGPL-3.0";
|
||||
fullName = "GNU Affero General Public License v3.0";
|
||||
deprecated = true;
|
||||
};
|
||||
fdl11 = spdx {
|
||||
spdxId = "GFDL-1.1";
|
||||
fullName = "GNU Free Documentation License v1.1";
|
||||
deprecated = true;
|
||||
};
|
||||
fdl12 = spdx {
|
||||
spdxId = "GFDL-1.2";
|
||||
fullName = "GNU Free Documentation License v1.2";
|
||||
deprecated = true;
|
||||
};
|
||||
fdl13 = spdx {
|
||||
spdxId = "GFDL-1.3";
|
||||
fullName = "GNU Free Documentation License v1.3";
|
||||
deprecated = true;
|
||||
};
|
||||
gpl1 = spdx {
|
||||
spdxId = "GPL-1.0";
|
||||
fullName = "GNU General Public License v1.0";
|
||||
deprecated = true;
|
||||
};
|
||||
gpl2 = spdx {
|
||||
spdxId = "GPL-2.0";
|
||||
fullName = "GNU General Public License v2.0";
|
||||
deprecated = true;
|
||||
};
|
||||
gpl3 = spdx {
|
||||
spdxId = "GPL-3.0";
|
||||
fullName = "GNU General Public License v3.0";
|
||||
deprecated = true;
|
||||
};
|
||||
lgpl2 = spdx {
|
||||
spdxId = "LGPL-2.0";
|
||||
fullName = "GNU Library General Public License v2";
|
||||
deprecated = true;
|
||||
};
|
||||
lgpl21 = spdx {
|
||||
spdxId = "LGPL-2.1";
|
||||
fullName = "GNU Lesser General Public License v2.1";
|
||||
deprecated = true;
|
||||
};
|
||||
lgpl3 = spdx {
|
||||
spdxId = "LGPL-3.0";
|
||||
fullName = "GNU Lesser General Public License v3.0";
|
||||
deprecated = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# General list operations.
|
||||
|
||||
{ lib }:
|
||||
with lib.trivial;
|
||||
let
|
||||
inherit (lib.strings) toInt;
|
||||
inherit (lib.trivial) compare min;
|
||||
in
|
||||
rec {
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -1,12 +1,53 @@
|
||||
{ lib }:
|
||||
|
||||
with lib.lists;
|
||||
with lib.strings;
|
||||
with lib.trivial;
|
||||
with lib.attrsets;
|
||||
with lib.options;
|
||||
with lib.debug;
|
||||
with lib.types;
|
||||
let
|
||||
inherit (lib)
|
||||
all
|
||||
any
|
||||
attrByPath
|
||||
attrNames
|
||||
catAttrs
|
||||
concatLists
|
||||
concatMap
|
||||
count
|
||||
elem
|
||||
filter
|
||||
findFirst
|
||||
flip
|
||||
foldl
|
||||
foldl'
|
||||
getAttrFromPath
|
||||
head
|
||||
id
|
||||
imap1
|
||||
isAttrs
|
||||
isBool
|
||||
isFunction
|
||||
isString
|
||||
length
|
||||
mapAttrs
|
||||
mapAttrsToList
|
||||
mapAttrsRecursiveCond
|
||||
min
|
||||
optional
|
||||
optionalAttrs
|
||||
optionalString
|
||||
recursiveUpdate
|
||||
reverseList sort
|
||||
setAttrByPath
|
||||
toList
|
||||
types
|
||||
warn
|
||||
;
|
||||
inherit (lib.options)
|
||||
isOption
|
||||
mkOption
|
||||
showDefs
|
||||
showFiles
|
||||
showOption
|
||||
unknownModule
|
||||
;
|
||||
in
|
||||
|
||||
rec {
|
||||
|
||||
@@ -224,7 +265,7 @@ rec {
|
||||
if badAttrs != {} then
|
||||
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: ${toString (attrNames badAttrs)}) into the explicit `config' attribute."
|
||||
else
|
||||
{ _file = m._file or file;
|
||||
{ _file = toString m._file or file;
|
||||
key = toString m.key or key;
|
||||
disabledModules = m.disabledModules or [];
|
||||
imports = m.imports or [];
|
||||
@@ -232,7 +273,7 @@ rec {
|
||||
config = addFreeformType (addMeta (m.config or {}));
|
||||
}
|
||||
else
|
||||
{ _file = m._file or file;
|
||||
{ _file = toString m._file or file;
|
||||
key = toString m.key or key;
|
||||
disabledModules = m.disabledModules or [];
|
||||
imports = m.require or [] ++ m.imports or [];
|
||||
@@ -616,7 +657,7 @@ rec {
|
||||
fixupOptionType = loc: opt:
|
||||
let
|
||||
options = opt.options or
|
||||
(throw "Option `${showOption loc'}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}.");
|
||||
(throw "Option `${showOption loc}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}.");
|
||||
f = tp:
|
||||
let optionSetIn = type: (tp.name == type) && (tp.functor.wrapped.name == "optionSet");
|
||||
in
|
||||
@@ -719,7 +760,7 @@ rec {
|
||||
|
||||
mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>"
|
||||
|
||||
causes a warning if the user defines boot.loader.grub.bootDevice.
|
||||
causes a assertion if the user defines boot.loader.grub.bootDevice.
|
||||
|
||||
replacementInstructions is a string that provides instructions on
|
||||
how to achieve the same functionality without the removed option,
|
||||
|
||||
@@ -1,11 +1,40 @@
|
||||
# Nixpkgs/NixOS option handling.
|
||||
{ lib }:
|
||||
|
||||
with lib.trivial;
|
||||
with lib.lists;
|
||||
with lib.attrsets;
|
||||
with lib.strings;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
all
|
||||
collect
|
||||
concatLists
|
||||
concatMap
|
||||
elemAt
|
||||
filter
|
||||
foldl'
|
||||
head
|
||||
isAttrs
|
||||
isBool
|
||||
isDerivation
|
||||
isFunction
|
||||
isInt
|
||||
isList
|
||||
isString
|
||||
length
|
||||
mapAttrs
|
||||
optional
|
||||
optionals
|
||||
take
|
||||
;
|
||||
inherit (lib.attrsets)
|
||||
optionalAttrs
|
||||
;
|
||||
inherit (lib.strings)
|
||||
concatMapStrings
|
||||
concatStringsSep
|
||||
;
|
||||
inherit (lib.types)
|
||||
mkOptionType
|
||||
;
|
||||
in
|
||||
rec {
|
||||
|
||||
/* Returns true when the given argument is an option
|
||||
@@ -110,7 +139,7 @@ rec {
|
||||
# Return early if we only have one element
|
||||
# This also makes it work for functions, because the foldl' below would try
|
||||
# to compare the first element with itself, which is false for functions
|
||||
else if length defs == 1 then (elemAt defs 0).value
|
||||
else if length defs == 1 then (head defs).value
|
||||
else (foldl' (first: def:
|
||||
if def.value != first.value then
|
||||
throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}"
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
# Functions for copying sources to the Nix store.
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (builtins)
|
||||
hasContext
|
||||
match
|
||||
readDir
|
||||
split
|
||||
storeDir
|
||||
tryEval
|
||||
;
|
||||
inherit (lib)
|
||||
filter
|
||||
getAttr
|
||||
isString
|
||||
pathExists
|
||||
readFile
|
||||
;
|
||||
in
|
||||
rec {
|
||||
|
||||
# Returns the type of a path: regular (for file), symlink, or directory
|
||||
pathType = p: with builtins; getAttr (baseNameOf p) (readDir (dirOf p));
|
||||
pathType = p: getAttr (baseNameOf p) (readDir (dirOf p));
|
||||
|
||||
# Returns true if the path exists and is a directory, false otherwise
|
||||
pathIsDirectory = p: if builtins.pathExists p then (pathType p) == "directory" else false;
|
||||
pathIsDirectory = p: if pathExists p then (pathType p) == "directory" else false;
|
||||
|
||||
# Returns true if the path exists and is a regular file, false otherwise
|
||||
pathIsRegularFile = p: if builtins.pathExists p then (pathType p) == "regular" else false;
|
||||
pathIsRegularFile = p: if pathExists p then (pathType p) == "regular" else false;
|
||||
|
||||
# Bring in a path as a source, filtering out all Subversion and CVS
|
||||
# directories, as well as backup files (*~).
|
||||
@@ -19,8 +36,8 @@ rec {
|
||||
(baseName == ".git" || type == "directory" && (baseName == ".svn" || baseName == "CVS" || baseName == ".hg")) ||
|
||||
# Filter out editor backup / swap files.
|
||||
lib.hasSuffix "~" baseName ||
|
||||
builtins.match "^\\.sw[a-z]$" baseName != null ||
|
||||
builtins.match "^\\..*\\.sw[a-z]$" baseName != null ||
|
||||
match "^\\.sw[a-z]$" baseName != null ||
|
||||
match "^\\..*\\.sw[a-z]$" baseName != null ||
|
||||
|
||||
# Filter out generates files.
|
||||
lib.hasSuffix ".o" baseName ||
|
||||
@@ -89,7 +106,7 @@ rec {
|
||||
in lib.cleanSourceWith {
|
||||
filter = (path: type:
|
||||
let relPath = lib.removePrefix (toString origSrc + "/") (toString path);
|
||||
in lib.any (re: builtins.match re relPath != null) regexes);
|
||||
in lib.any (re: match re relPath != null) regexes);
|
||||
inherit src;
|
||||
};
|
||||
|
||||
@@ -102,13 +119,12 @@ rec {
|
||||
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
||||
in cleanSourceWith { inherit filter; src = path; };
|
||||
|
||||
pathIsGitRepo = path: (builtins.tryEval (commitIdFromGitRepo path)).success;
|
||||
pathIsGitRepo = path: (tryEval (commitIdFromGitRepo path)).success;
|
||||
|
||||
# Get the commit id of a git repo
|
||||
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
||||
commitIdFromGitRepo =
|
||||
let readCommitFromFile = file: path:
|
||||
with builtins;
|
||||
let fileName = toString path + "/" + file;
|
||||
packedRefsName = toString path + "/packed-refs";
|
||||
absolutePath = base: path:
|
||||
@@ -145,11 +161,11 @@ rec {
|
||||
# packed-refs file, so we have to grep through it:
|
||||
then
|
||||
let fileContent = readFile packedRefsName;
|
||||
matchRef = builtins.match "([a-z0-9]+) ${file}";
|
||||
isRef = s: builtins.isString s && (matchRef s) != null;
|
||||
matchRef = match "([a-z0-9]+) ${file}";
|
||||
isRef = s: isString s && (matchRef s) != null;
|
||||
# there is a bug in libstdc++ leading to stackoverflow for long strings:
|
||||
# https://github.com/NixOS/nix/issues/2147#issuecomment-659868795
|
||||
refs = builtins.filter isRef (builtins.split "\n" fileContent);
|
||||
refs = filter isRef (split "\n" fileContent);
|
||||
in if refs == []
|
||||
then throw ("Could not find " + file + " in " + packedRefsName)
|
||||
else lib.head (matchRef (lib.head refs))
|
||||
@@ -157,7 +173,7 @@ rec {
|
||||
else throw ("Not a .git directory: " + path);
|
||||
in readCommitFromFile "HEAD";
|
||||
|
||||
pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
|
||||
pathHasContext = builtins.hasContext or (lib.hasPrefix storeDir);
|
||||
|
||||
canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext (toString src));
|
||||
}
|
||||
|
||||
@@ -41,10 +41,15 @@ Usage:
|
||||
[1] maybe this behaviour should be removed to keep things simple (?)
|
||||
*/
|
||||
|
||||
with lib.lists;
|
||||
with lib.attrsets;
|
||||
with lib.strings;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
concatStringsSep
|
||||
head
|
||||
isAttrs
|
||||
listToAttrs
|
||||
tail
|
||||
;
|
||||
in
|
||||
rec {
|
||||
|
||||
/* !!! The interface of this function is kind of messed up, since
|
||||
|
||||
117
lib/strings.nix
117
lib/strings.nix
@@ -8,7 +8,29 @@ in
|
||||
|
||||
rec {
|
||||
|
||||
inherit (builtins) stringLength substring head tail isString replaceStrings;
|
||||
inherit (builtins)
|
||||
compareVersions
|
||||
elem
|
||||
elemAt
|
||||
filter
|
||||
fromJSON
|
||||
head
|
||||
isInt
|
||||
isList
|
||||
isString
|
||||
match
|
||||
parseDrvName
|
||||
readFile
|
||||
replaceStrings
|
||||
split
|
||||
storeDir
|
||||
stringLength
|
||||
substring
|
||||
tail
|
||||
toJSON
|
||||
typeOf
|
||||
unsafeDiscardStringContext
|
||||
;
|
||||
|
||||
/* Concatenate a list of strings.
|
||||
|
||||
@@ -120,7 +142,7 @@ rec {
|
||||
subDir:
|
||||
# List of base paths
|
||||
paths:
|
||||
concatStringsSep ":" (map (path: path + "/" + subDir) (builtins.filter (x: x != null) paths));
|
||||
concatStringsSep ":" (map (path: path + "/" + subDir) (filter (x: x != null) paths));
|
||||
|
||||
/* Construct a Unix-style search path by appending the given
|
||||
`subDir` to the specified `output` of each of the packages. If no
|
||||
@@ -313,7 +335,17 @@ rec {
|
||||
escapeNixString "hello\${}\n"
|
||||
=> "\"hello\\\${}\\n\""
|
||||
*/
|
||||
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
||||
escapeNixString = s: escape ["$"] (toJSON s);
|
||||
|
||||
/* Turn a string into an exact regular expression
|
||||
|
||||
Type: string -> string
|
||||
|
||||
Example:
|
||||
escapeRegex "[^a-z]*"
|
||||
=> "\\[\\^a-z]\\*"
|
||||
*/
|
||||
escapeRegex = escape (stringToCharacters "\\[{()^$?*+|.");
|
||||
|
||||
/* Quotes a string if it can't be used as an identifier directly.
|
||||
|
||||
@@ -327,7 +359,7 @@ rec {
|
||||
*/
|
||||
escapeNixIdentifier = s:
|
||||
# Regex from https://github.com/NixOS/nix/blob/d048577909e383439c2549e849c5c2f2016c997e/src/libexpr/lexer.l#L91
|
||||
if builtins.match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
|
||||
if match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
|
||||
then s else escapeNixString s;
|
||||
|
||||
# Obsolete - use replaceStrings instead.
|
||||
@@ -386,8 +418,6 @@ rec {
|
||||
/* Cut a string with a separator and produces a list of strings which
|
||||
were separated by this separator.
|
||||
|
||||
NOTE: this function is not performant and should never be used.
|
||||
|
||||
Example:
|
||||
splitString "." "foo.bar.baz"
|
||||
=> [ "foo" "bar" "baz" ]
|
||||
@@ -396,26 +426,11 @@ rec {
|
||||
*/
|
||||
splitString = _sep: _s:
|
||||
let
|
||||
sep = addContextFrom _s _sep;
|
||||
s = addContextFrom _sep _s;
|
||||
sepLen = stringLength sep;
|
||||
sLen = stringLength s;
|
||||
lastSearch = sLen - sepLen;
|
||||
startWithSep = startAt:
|
||||
substring startAt sepLen s == sep;
|
||||
|
||||
recurse = index: startAt:
|
||||
let cutUntil = i: [(substring startAt (i - startAt) s)]; in
|
||||
if index <= lastSearch then
|
||||
if startWithSep index then
|
||||
let restartAt = index + sepLen; in
|
||||
cutUntil index ++ recurse restartAt restartAt
|
||||
else
|
||||
recurse (index + 1) startAt
|
||||
else
|
||||
cutUntil sLen;
|
||||
sep = builtins.unsafeDiscardStringContext _sep;
|
||||
s = builtins.unsafeDiscardStringContext _s;
|
||||
splits = builtins.filter builtins.isString (builtins.split (escapeRegex sep) s);
|
||||
in
|
||||
recurse 0 0;
|
||||
map (v: addContextFrom _sep (addContextFrom _s v)) splits;
|
||||
|
||||
/* Return a string without the specified prefix, if the prefix matches.
|
||||
|
||||
@@ -473,7 +488,7 @@ rec {
|
||||
versionOlder "1.1" "1.1"
|
||||
=> false
|
||||
*/
|
||||
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
|
||||
versionOlder = v1: v2: compareVersions v2 v1 == 1;
|
||||
|
||||
/* Return true if string v1 denotes a version equal to or newer than v2.
|
||||
|
||||
@@ -499,7 +514,7 @@ rec {
|
||||
*/
|
||||
getName = x:
|
||||
let
|
||||
parse = drv: (builtins.parseDrvName drv).name;
|
||||
parse = drv: (parseDrvName drv).name;
|
||||
in if isString x
|
||||
then parse x
|
||||
else x.pname or (parse x.name);
|
||||
@@ -516,7 +531,7 @@ rec {
|
||||
*/
|
||||
getVersion = x:
|
||||
let
|
||||
parse = drv: (builtins.parseDrvName drv).version;
|
||||
parse = drv: (parseDrvName drv).version;
|
||||
in if isString x
|
||||
then parse x
|
||||
else x.version or (parse x.name);
|
||||
@@ -534,7 +549,7 @@ rec {
|
||||
let
|
||||
components = splitString "/" url;
|
||||
filename = lib.last components;
|
||||
name = builtins.head (splitString sep filename);
|
||||
name = head (splitString sep filename);
|
||||
in assert name != filename; name;
|
||||
|
||||
/* Create an --{enable,disable}-<feat> string that can be passed to
|
||||
@@ -546,15 +561,17 @@ 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.
|
||||
|
||||
Example:
|
||||
enableFeature true "shared" "foo"
|
||||
enableFeatureAs true "shared" "foo"
|
||||
=> "--enable-shared=foo"
|
||||
enableFeature false "shared" (throw "ignored")
|
||||
enableFeatureAs false "shared" (throw "ignored")
|
||||
=> "--disable-shared"
|
||||
*/
|
||||
enableFeatureAs = enable: feat: value: enableFeature enable feat + optionalString enable "=${value}";
|
||||
@@ -568,15 +585,17 @@ 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.
|
||||
|
||||
Example:
|
||||
with_Feature true "shared" "foo"
|
||||
withFeatureAs true "shared" "foo"
|
||||
=> "--with-shared=foo"
|
||||
with_Feature false "shared" (throw "ignored")
|
||||
withFeatureAs false "shared" (throw "ignored")
|
||||
=> "--without-shared"
|
||||
*/
|
||||
withFeatureAs = with_: feat: value: withFeature with_ feat + optionalString with_ "=${value}";
|
||||
@@ -624,14 +643,14 @@ rec {
|
||||
*/
|
||||
floatToString = float: let
|
||||
result = toString float;
|
||||
precise = float == builtins.fromJSON result;
|
||||
precise = float == fromJSON result;
|
||||
in if precise then result
|
||||
else lib.warn "Imprecise conversion from float to string ${result}" result;
|
||||
|
||||
/* Check whether a value can be coerced to a string */
|
||||
isCoercibleToString = x:
|
||||
builtins.elem (builtins.typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
|
||||
(builtins.isList x && lib.all isCoercibleToString x) ||
|
||||
elem (typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
|
||||
(isList x && lib.all isCoercibleToString x) ||
|
||||
x ? outPath ||
|
||||
x ? __toString;
|
||||
|
||||
@@ -650,12 +669,12 @@ rec {
|
||||
isStorePath = x:
|
||||
if isCoercibleToString x then
|
||||
let str = toString x; in
|
||||
builtins.substring 0 1 str == "/"
|
||||
&& dirOf str == builtins.storeDir
|
||||
substring 0 1 str == "/"
|
||||
&& dirOf str == storeDir
|
||||
else
|
||||
false;
|
||||
|
||||
/* Parse a string string as an int.
|
||||
/* Parse a string as an int.
|
||||
|
||||
Type: string -> int
|
||||
|
||||
@@ -669,8 +688,8 @@ rec {
|
||||
*/
|
||||
# Obviously, it is a bit hacky to use fromJSON this way.
|
||||
toInt = str:
|
||||
let may_be_int = builtins.fromJSON str; in
|
||||
if builtins.isInt may_be_int
|
||||
let may_be_int = fromJSON str; in
|
||||
if isInt may_be_int
|
||||
then may_be_int
|
||||
else throw "Could not convert ${str} to int.";
|
||||
|
||||
@@ -692,10 +711,10 @@ rec {
|
||||
readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead"
|
||||
(rootPath: file:
|
||||
let
|
||||
lines = lib.splitString "\n" (builtins.readFile file);
|
||||
lines = lib.splitString "\n" (readFile file);
|
||||
removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
|
||||
relativePaths = removeComments lines;
|
||||
absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths;
|
||||
absolutePaths = map (path: rootPath + "/${path}") relativePaths;
|
||||
in
|
||||
absolutePaths);
|
||||
|
||||
@@ -709,7 +728,7 @@ rec {
|
||||
fileContents ./version
|
||||
=> "1.0"
|
||||
*/
|
||||
fileContents = file: removeSuffix "\n" (builtins.readFile file);
|
||||
fileContents = file: removeSuffix "\n" (readFile file);
|
||||
|
||||
|
||||
/* Creates a valid derivation name from a potentially invalid one.
|
||||
@@ -727,13 +746,13 @@ rec {
|
||||
sanitizeDerivationName = string: lib.pipe string [
|
||||
# Get rid of string context. This is safe under the assumption that the
|
||||
# resulting string is only used as a derivation name
|
||||
builtins.unsafeDiscardStringContext
|
||||
unsafeDiscardStringContext
|
||||
# Strip all leading "."
|
||||
(x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0)
|
||||
(x: elemAt (match "\\.*(.*)" x) 0)
|
||||
# Split out all invalid characters
|
||||
# https://github.com/NixOS/nix/blob/2.3.2/src/libstore/store-api.cc#L85-L112
|
||||
# https://github.com/NixOS/nix/blob/2242be83c61788b9c0736a92bb0b5c7bbfc40803/nix-rust/src/store/path.rs#L100-L125
|
||||
(builtins.split "[^[:alnum:]+._?=-]+")
|
||||
(split "[^[:alnum:]+._?=-]+")
|
||||
# Replace invalid character ranges with a "-"
|
||||
(concatMapStrings (s: if lib.isList s then "-" else s))
|
||||
# Limit to 211 characters (minus 4 chars for ".drv")
|
||||
|
||||
@@ -12,6 +12,12 @@ rec {
|
||||
broadwell = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "fma" ];
|
||||
skylake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "fma" ];
|
||||
skylake-avx512 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
cannonlake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
icelake-client = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
icelake-server = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
cascadelake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
cooperlake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
tigerlake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
|
||||
# x86_64 AMD
|
||||
btver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" ];
|
||||
btver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ];
|
||||
@@ -21,6 +27,7 @@ rec {
|
||||
bdver4 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" "fma4" ];
|
||||
znver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ];
|
||||
znver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ];
|
||||
znver3 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ];
|
||||
# other
|
||||
armv5te = [ ];
|
||||
armv6 = [ ];
|
||||
@@ -41,15 +48,38 @@ rec {
|
||||
broadwell = [ "haswell" ] ++ inferiors.haswell;
|
||||
skylake = [ "broadwell" ] ++ inferiors.broadwell;
|
||||
skylake-avx512 = [ "skylake" ] ++ inferiors.skylake;
|
||||
|
||||
# x86_64 AMD
|
||||
# TODO: fill this (need testing)
|
||||
btver1 = [ ];
|
||||
btver2 = [ ]; # TODO: fill this (need testing)
|
||||
bdver1 = [ ]; # TODO: fill this (need testing)
|
||||
bdver2 = [ ]; # TODO: fill this (need testing)
|
||||
bdver3 = [ ]; # TODO: fill this (need testing)
|
||||
bdver4 = [ ]; # TODO: fill this (need testing)
|
||||
znver1 = [ ]; # TODO: fill this (need testing)
|
||||
znver2 = [ ]; # TODO: fill this (need testing)
|
||||
btver2 = [ ];
|
||||
bdver1 = [ ];
|
||||
bdver2 = [ ];
|
||||
bdver3 = [ ];
|
||||
bdver4 = [ ];
|
||||
# Regarding `skylake` as inferior of `znver1`, there are reports of
|
||||
# successful usage by Gentoo users and Phoronix benchmarking of different
|
||||
# `-march` targets.
|
||||
#
|
||||
# The GCC documentation on extensions used and wikichip documentation
|
||||
# regarding supperted extensions on znver1 and skylake was used to create
|
||||
# this partial order.
|
||||
#
|
||||
# Note:
|
||||
#
|
||||
# - The succesors of `skylake` (`cannonlake`, `icelake`, etc) use `avx512`
|
||||
# which no current AMD Zen michroarch support.
|
||||
# - `znver1` uses `ABM`, `CLZERO`, `CX16`, `MWAITX`, and `SSE4A` which no
|
||||
# current Intel microarch support.
|
||||
#
|
||||
# https://www.phoronix.com/scan.php?page=article&item=amd-znver3-gcc11&num=1
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||
# https://en.wikichip.org/wiki/amd/microarchitectures/zen
|
||||
# https://en.wikichip.org/wiki/intel/microarchitectures/skylake
|
||||
znver1 = [ "skylake" ] ++ inferiors.skylake;
|
||||
znver2 = [ "znver1" ] ++ inferiors.znver1;
|
||||
znver3 = [ "znver2" ] ++ inferiors.znver2;
|
||||
|
||||
# other
|
||||
armv5te = [ ];
|
||||
armv6 = [ ];
|
||||
|
||||
@@ -25,7 +25,7 @@ rec {
|
||||
system = parse.doubleFromSystem final.parsed;
|
||||
config = parse.tripleFromSystem final.parsed;
|
||||
# Just a guess, based on `system`
|
||||
platform = platforms.selectBySystem final.system;
|
||||
platform = platforms.select final;
|
||||
# Determine whether we are compatible with the provided CPU
|
||||
isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
|
||||
# Derived meta-data
|
||||
@@ -83,7 +83,7 @@ rec {
|
||||
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 if final.isx86_64 then "x86"
|
||||
else if final.isMips then "mips"
|
||||
else final.parsed.cpu.name;
|
||||
|
||||
@@ -124,6 +124,8 @@ rec {
|
||||
then "${qemu-user}/bin/qemu-${final.qemuArch}"
|
||||
else if final.isWasi
|
||||
then "${pkgs.wasmtime}/bin/wasmtime"
|
||||
else if final.isMmix
|
||||
then "${pkgs.mmixware}/bin/mmix"
|
||||
else throw "Don't know how to run ${final.config} executables.";
|
||||
|
||||
} // mapAttrs (n: v: v final.parsed) inspect.predicates
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -7,7 +7,7 @@ let
|
||||
|
||||
riscv = bits: {
|
||||
config = "riscv${bits}-unknown-linux-gnu";
|
||||
platform = platforms.riscv-multiplatform bits;
|
||||
platform = platforms.riscv-multiplatform;
|
||||
};
|
||||
in
|
||||
|
||||
@@ -34,6 +34,16 @@ rec {
|
||||
platform = platforms.raspberrypi;
|
||||
};
|
||||
|
||||
remarkable1 = {
|
||||
config = "armv7l-unknown-linux-gnueabihf";
|
||||
platform = platforms.zero-gravitas;
|
||||
};
|
||||
|
||||
remarkable2 = {
|
||||
config = "armv7l-unknown-linux-gnueabihf";
|
||||
platform = platforms.zero-sugar;
|
||||
};
|
||||
|
||||
armv7l-hf-multiplatform = {
|
||||
config = "armv7l-unknown-linux-gnueabihf";
|
||||
platform = platforms.armv7l-hf-multiplatform;
|
||||
@@ -100,13 +110,18 @@ rec {
|
||||
riscv64-embedded = {
|
||||
config = "riscv64-none-elf";
|
||||
libc = "newlib";
|
||||
platform = platforms.riscv-multiplatform "64";
|
||||
platform = platforms.riscv-multiplatform;
|
||||
};
|
||||
|
||||
riscv32-embedded = {
|
||||
config = "riscv32-none-elf";
|
||||
libc = "newlib";
|
||||
platform = platforms.riscv-multiplatform "32";
|
||||
platform = platforms.riscv-multiplatform;
|
||||
};
|
||||
|
||||
mmix = {
|
||||
config = "mmix-unknown-mmixware";
|
||||
libc = "newlib";
|
||||
};
|
||||
|
||||
msp430 = {
|
||||
@@ -124,6 +139,12 @@ rec {
|
||||
platform = {};
|
||||
};
|
||||
|
||||
or1k = {
|
||||
config = "or1k-elf";
|
||||
libc = "newlib";
|
||||
platform = {};
|
||||
};
|
||||
|
||||
arm-embedded = {
|
||||
config = "arm-none-eabi";
|
||||
libc = "newlib";
|
||||
|
||||
@@ -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; }; };
|
||||
|
||||
@@ -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"])
|
||||
|
||||
@@ -47,7 +47,6 @@ rec {
|
||||
arch = "armv5te";
|
||||
};
|
||||
|
||||
kernelMajor = "2.6";
|
||||
kernelBaseConfig = "multi_v5_defconfig";
|
||||
kernelArch = "arm";
|
||||
kernelAutoModules = false;
|
||||
@@ -70,7 +69,6 @@ rec {
|
||||
|
||||
sheevaplug = {
|
||||
name = "sheevaplug";
|
||||
kernelMajor = "2.6";
|
||||
kernelBaseConfig = "multi_v5_defconfig";
|
||||
kernelArch = "arm";
|
||||
kernelAutoModules = false;
|
||||
@@ -182,7 +180,6 @@ rec {
|
||||
|
||||
raspberrypi = {
|
||||
name = "raspberrypi";
|
||||
kernelMajor = "2.6";
|
||||
kernelBaseConfig = "bcm2835_defconfig";
|
||||
kernelDTB = true;
|
||||
kernelArch = "arm";
|
||||
@@ -203,6 +200,35 @@ 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";
|
||||
};
|
||||
};
|
||||
|
||||
zero-sugar = {
|
||||
name = "zero-sugar";
|
||||
kernelBaseConfig = "zero-sugar_defconfig";
|
||||
kernelArch = "arm";
|
||||
kernelDTB = true;
|
||||
kernelAutoModules = false;
|
||||
kernelPreferBuiltin = true;
|
||||
kernelTarget = "zImage";
|
||||
gcc = {
|
||||
cpu = "cortex-a7";
|
||||
fpu = "neon-vfpv4";
|
||||
float-abi = "hard";
|
||||
};
|
||||
};
|
||||
|
||||
scaleway-c1 = armv7l-hf-multiplatform // {
|
||||
gcc = {
|
||||
cpu = "cortex-a9";
|
||||
@@ -212,7 +238,6 @@ rec {
|
||||
|
||||
utilite = {
|
||||
name = "utilite";
|
||||
kernelMajor = "2.6";
|
||||
kernelBaseConfig = "multi_v7_defconfig";
|
||||
kernelArch = "arm";
|
||||
kernelAutoModules = false;
|
||||
@@ -265,7 +290,6 @@ rec {
|
||||
|
||||
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;
|
||||
@@ -313,7 +337,6 @@ rec {
|
||||
|
||||
aarch64-multiplatform = {
|
||||
name = "aarch64-multiplatform";
|
||||
kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
|
||||
kernelBaseConfig = "defconfig";
|
||||
kernelArch = "arm64";
|
||||
kernelDTB = true;
|
||||
@@ -352,7 +375,6 @@ rec {
|
||||
|
||||
ben_nanonote = {
|
||||
name = "ben_nanonote";
|
||||
kernelMajor = "2.6";
|
||||
kernelArch = "mips";
|
||||
gcc = {
|
||||
arch = "mips32";
|
||||
@@ -362,7 +384,6 @@ rec {
|
||||
|
||||
fuloong2f_n32 = {
|
||||
name = "fuloong2f_n32";
|
||||
kernelMajor = "2.6";
|
||||
kernelBaseConfig = "lemote2f_defconfig";
|
||||
kernelArch = "mips";
|
||||
kernelAutoModules = false;
|
||||
@@ -442,10 +463,9 @@ rec {
|
||||
## Other
|
||||
##
|
||||
|
||||
riscv-multiplatform = bits: {
|
||||
riscv-multiplatform = {
|
||||
name = "riscv-multiplatform";
|
||||
kernelArch = "riscv";
|
||||
bfdEmulation = "elf${bits}lriscv";
|
||||
kernelTarget = "vmlinux";
|
||||
kernelAutoModules = true;
|
||||
kernelBaseConfig = "defconfig";
|
||||
@@ -455,17 +475,23 @@ rec {
|
||||
'';
|
||||
};
|
||||
|
||||
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;
|
||||
select = platform:
|
||||
# x86
|
||||
/**/ if platform.isx86_32 then pc32
|
||||
else if platform.isx86_64 then pc64
|
||||
|
||||
# ARM
|
||||
else if platform.isAarch32 then let
|
||||
version = platform.parsed.cpu.version or null;
|
||||
in if version == null then pcBase
|
||||
else if lib.versionOlder version "6" then sheevaplug
|
||||
else if lib.versionOlder version "7" then raspberrypi
|
||||
else armv7l-hf-multiplatform
|
||||
else if platform.isAarch64 then aarch64-multiplatform
|
||||
|
||||
else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32
|
||||
|
||||
else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv
|
||||
|
||||
else pcBase;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -154,6 +174,20 @@ runTests {
|
||||
expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ];
|
||||
};
|
||||
|
||||
testSplitStringsRegex = {
|
||||
expr = strings.splitString "\\[{}]()^$?*+|." "A\\[{}]()^$?*+|.B";
|
||||
expected = [ "A" "B" ];
|
||||
};
|
||||
|
||||
testSplitStringsDerivation = {
|
||||
expr = take 3 (strings.splitString "/" (derivation {
|
||||
name = "name";
|
||||
builder = "builder";
|
||||
system = "system";
|
||||
}));
|
||||
expected = ["" "nix" "store"];
|
||||
};
|
||||
|
||||
testSplitVersionSingle = {
|
||||
expr = versions.splitVersion "1";
|
||||
expected = [ "1" ];
|
||||
|
||||
@@ -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" ];
|
||||
|
||||
@@ -1,12 +1,65 @@
|
||||
# Definitions related to run-time type checking. Used in particular
|
||||
# to type-check NixOS configurations.
|
||||
{ lib }:
|
||||
with lib.lists;
|
||||
with lib.attrsets;
|
||||
with lib.options;
|
||||
with lib.trivial;
|
||||
with lib.strings;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
elem
|
||||
flip
|
||||
functionArgs
|
||||
isAttrs
|
||||
isBool
|
||||
isDerivation
|
||||
isFloat
|
||||
isFunction
|
||||
isInt
|
||||
isList
|
||||
isString
|
||||
isStorePath
|
||||
setFunctionArgs
|
||||
toDerivation
|
||||
toList
|
||||
;
|
||||
inherit (lib.lists)
|
||||
all
|
||||
concatLists
|
||||
count
|
||||
elemAt
|
||||
filter
|
||||
foldl'
|
||||
head
|
||||
imap1
|
||||
last
|
||||
length
|
||||
tail
|
||||
unique
|
||||
;
|
||||
inherit (lib.attrsets)
|
||||
attrNames
|
||||
filterAttrs
|
||||
hasAttr
|
||||
mapAttrs
|
||||
optionalAttrs
|
||||
zipAttrsWith
|
||||
;
|
||||
inherit (lib.options)
|
||||
getFiles
|
||||
getValues
|
||||
mergeDefaultOption
|
||||
mergeEqualOption
|
||||
mergeOneOption
|
||||
showFiles
|
||||
showOption
|
||||
;
|
||||
inherit (lib.strings)
|
||||
concatMapStringsSep
|
||||
concatStringsSep
|
||||
escapeNixString
|
||||
isCoercibleToString
|
||||
;
|
||||
inherit (lib.trivial)
|
||||
boolToString
|
||||
;
|
||||
|
||||
inherit (lib.modules) mergeDefinitions;
|
||||
outer_types =
|
||||
@@ -270,7 +323,7 @@ rec {
|
||||
name = "attrs";
|
||||
description = "attribute set";
|
||||
check = isAttrs;
|
||||
merge = loc: foldl' (res: def: mergeAttrs res def.value) {};
|
||||
merge = loc: foldl' (res: def: res // def.value) {};
|
||||
emptyValue = { value = {}; };
|
||||
};
|
||||
|
||||
@@ -499,7 +552,7 @@ rec {
|
||||
show = v:
|
||||
if builtins.isString v then ''"${v}"''
|
||||
else if builtins.isInt v then builtins.toString v
|
||||
else if builtins.isBool v then if v then "true" else "false"
|
||||
else if builtins.isBool v then boolToString v
|
||||
else ''<${builtins.typeOf v}>'';
|
||||
in
|
||||
mkOptionType rec {
|
||||
|
||||
Reference in New Issue
Block a user