2017-03-30 21:03:40 +01:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
|
|
|
* for new functions in `./tests.nix'.
|
|
|
|
*/
|
2016-09-15 00:21:42 +01:00
|
|
|
let
|
2006-09-25 11:07:59 +01:00
|
|
|
|
2018-04-06 17:51:10 +01:00
|
|
|
inherit (import ./fixed-points.nix {}) makeExtensible;
|
2017-07-29 01:05:35 +01:00
|
|
|
|
2018-04-06 17:51:10 +01:00
|
|
|
lib = makeExtensible (self: let
|
|
|
|
callLibs = file: import file { lib = self; };
|
|
|
|
in with self; {
|
2017-07-29 01:05:35 +01:00
|
|
|
|
|
|
|
# often used, or depending on very little
|
|
|
|
trivial = callLibs ./trivial.nix;
|
|
|
|
fixedPoints = callLibs ./fixed-points.nix;
|
|
|
|
|
|
|
|
# datatypes
|
|
|
|
attrsets = callLibs ./attrsets.nix;
|
|
|
|
lists = callLibs ./lists.nix;
|
|
|
|
strings = callLibs ./strings.nix;
|
|
|
|
stringsWithDeps = callLibs ./strings-with-deps.nix;
|
|
|
|
|
|
|
|
# packaging
|
|
|
|
customisation = callLibs ./customisation.nix;
|
2018-03-04 03:09:35 +00:00
|
|
|
maintainers = import ../maintainers/maintainer-list.nix;
|
2017-07-29 01:05:35 +01:00
|
|
|
meta = callLibs ./meta.nix;
|
|
|
|
sources = callLibs ./sources.nix;
|
2018-03-03 04:26:32 +00:00
|
|
|
versions = callLibs ./versions.nix;
|
2017-07-29 01:05:35 +01:00
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
|
|
|
# misc
|
|
|
|
debug = callLibs ./debug.nix;
|
|
|
|
|
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
misc = callLibs ./deprecated.nix;
|
|
|
|
# domain-specific
|
|
|
|
fetchers = callLibs ./fetchers.nix;
|
|
|
|
|
|
|
|
# Eval-time filesystem handling
|
|
|
|
filesystem = callLibs ./filesystem.nix;
|
2017-02-09 02:27:22 +00:00
|
|
|
|
|
|
|
# back-compat aliases
|
lib, stdenv: Check `meta.platforms` against host platform and be open world
First, we need check against the host platform, not the build platform.
That's simple enough.
Second, we move away from exahustive finite case analysis (i.e.
exhaustively listing all platforms the package builds on). That only
work in a closed-world setting, where we know all platforms we might
build one. But with cross compilation, we may be building for arbitrary
platforms, So we need fancier filters. This is the closed world to open
world change.
The solution is instead of having a list of systems (strings in the form
"foo-bar"), we have a list of of systems or "patterns", i.e. attributes
that partially match the output of the parsers in `lib.systems.parse`.
The "check meta" logic treats the systems strings as an exact whitelist
just as before, but treats the patterns as a fuzzy whitelist,
intersecting the actual `hostPlatform` with the pattern and then
checking for equality. (This is done using `matchAttrs`).
The default convenience lists for `meta.platforms` are now changed to be
lists of patterns (usually a single pattern) in
`lib/systems/for-meta.nix` for maximum flexibility under this new
system.
Fixes #30902
2018-01-31 05:11:03 +00:00
|
|
|
platforms = systems.forMeta;
|
2017-07-29 01:05:35 +01:00
|
|
|
|
|
|
|
inherit (builtins) add addErrorContext attrNames
|
|
|
|
concatLists deepSeq elem elemAt filter genericClosure genList
|
2018-01-31 19:02:19 +00:00
|
|
|
getAttr hasAttr head isAttrs isBool isInt isList
|
2017-07-29 01:05:35 +01:00
|
|
|
isString length lessThan listToAttrs pathExists readFile
|
|
|
|
replaceStrings seq stringLength sub substring tail;
|
|
|
|
inherit (trivial) id const concat or and boolToString mergeAttrs
|
|
|
|
flip mapNullable inNixShell min max importJSON warn info
|
2017-12-07 21:26:30 +00:00
|
|
|
nixpkgsVersion mod compare splitByAndCompare
|
|
|
|
functionArgs setFunctionArgs isFunction;
|
2017-07-29 01:05:35 +01:00
|
|
|
|
|
|
|
inherit (fixedPoints) fix fix' extends composeExtensions
|
2017-09-29 14:10:48 +01:00
|
|
|
makeExtensible makeExtensibleWithCustomName;
|
2017-07-29 01:05:35 +01:00
|
|
|
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
|
|
|
getAttrFromPath attrVals attrValues catAttrs filterAttrs
|
|
|
|
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
|
|
|
mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
|
|
|
|
genAttrs isDerivation toDerivation optionalAttrs
|
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
|
|
|
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
|
|
|
getLib getDev chooseDevOutputs zipWithNames zip;
|
|
|
|
inherit (lists) singleton foldr fold foldl foldl' imap0 imap1
|
|
|
|
concatMap flatten remove findSingle findFirst any all count
|
|
|
|
optional optionals toList range partition zipListsWith zipLists
|
2018-04-08 11:55:06 +01:00
|
|
|
reverseList listDfs toposort sort naturalSort compareLists take drop sublist
|
2017-12-07 21:26:30 +00:00
|
|
|
last init crossLists unique intersectLists subtractLists
|
2017-07-29 01:05:35 +01:00
|
|
|
mutuallyExclusive;
|
|
|
|
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
|
|
|
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
|
|
|
makeLibraryPath makeBinPath makePerlPath optionalString
|
|
|
|
hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
|
|
|
escapeShellArg escapeShellArgs replaceChars lowerChars upperChars
|
|
|
|
toLower toUpper addContextFrom splitString removePrefix
|
|
|
|
removeSuffix versionOlder versionAtLeast getVersion nameFromURL
|
|
|
|
enableFeature fixedWidthString fixedWidthNumber isStorePath
|
|
|
|
toInt readPathsFromFile fileContents;
|
|
|
|
inherit (stringsWithDeps) textClosureList textClosureMap
|
|
|
|
noDepEntry fullDepEntry packEntry stringAfter;
|
|
|
|
inherit (customisation) overrideDerivation makeOverridable
|
2018-03-03 16:57:20 +00:00
|
|
|
callPackageWith callPackagesWith extendDerivation
|
2017-12-25 18:06:49 +00:00
|
|
|
hydraJob makeScope;
|
2017-07-29 01:05:35 +01:00
|
|
|
inherit (meta) addMetaAttrs dontDistribute setName updateName
|
|
|
|
appendToName mapDerivationAttrset lowPrio lowPrioSet hiPrio
|
|
|
|
hiPrioSet;
|
|
|
|
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
2018-01-11 15:17:56 +00:00
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext canCleanSource;
|
2017-07-29 01:05:35 +01:00
|
|
|
inherit (modules) evalModules closeModules unifyModuleSyntax
|
|
|
|
applyIfFunction unpackSubmodule packSubmodule mergeModules
|
|
|
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
|
|
|
pushDownProperties dischargeProperties filterOverrides
|
|
|
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
|
|
|
mkOptionDefault mkDefault mkForce mkVMOverride mkStrict
|
|
|
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
|
|
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
|
|
|
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
|
|
|
mkAliasOptionModule doRename filterModules;
|
|
|
|
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
|
|
|
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
|
|
|
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
|
|
|
scrubOptionValue literalExample showOption showFiles
|
|
|
|
unknownModule mkOption;
|
|
|
|
inherit (types) isType setType defaultTypeMerge defaultFunctor
|
|
|
|
isOptionType mkOptionType;
|
|
|
|
inherit (debug) addErrorContextToAttrs traceIf traceVal
|
|
|
|
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
|
|
|
traceValSeqN traceShowVal traceShowValMarked
|
|
|
|
showVal traceCall traceCall2 traceCall3 traceValIfNot runTests
|
|
|
|
testAllTrue strict traceCallXml attrNamesToStr;
|
|
|
|
inherit (misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
|
|
|
defaultOverridableDelayableArgs composedArgsAndFun
|
|
|
|
maybeAttrNullable maybeAttr ifEnable checkFlag getValue
|
|
|
|
checkReqs uniqList uniqListExt condConcat lazyGenericClosure
|
|
|
|
innerModifySumArgs modifySumArgs innerClosePropagation
|
|
|
|
closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
|
|
|
|
mergeAttrsWithFunc mergeAttrsConcatenateValues
|
|
|
|
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
|
|
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
|
|
|
prepareDerivationArgs nixType imap overridableDelayableArgs;
|
2018-04-06 17:51:10 +01:00
|
|
|
});
|
2017-07-29 01:05:35 +01:00
|
|
|
in lib
|