2017-03-30 20:03:40 +00:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
|
|
|
* for new functions in `./tests.nix'.
|
|
|
|
*/
|
2016-09-14 23:21:42 +00:00
|
|
|
let
|
2006-09-25 10:07:59 +00:00
|
|
|
|
2018-04-06 16:51:10 +00:00
|
|
|
inherit (import ./fixed-points.nix {}) makeExtensible;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
2018-04-06 16:51:10 +00:00
|
|
|
lib = makeExtensible (self: let
|
|
|
|
callLibs = file: import file { lib = self; };
|
|
|
|
in with self; {
|
2017-07-29 00:05:35 +00: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;
|
2019-10-27 21:44:24 +00:00
|
|
|
teams = callLibs ../maintainers/team-list.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
meta = callLibs ./meta.nix;
|
|
|
|
sources = callLibs ./sources.nix;
|
2018-03-03 04:26:32 +00:00
|
|
|
versions = callLibs ./versions.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
2020-01-22 22:22:23 +00:00
|
|
|
# serialization
|
|
|
|
cli = callLibs ./cli.nix;
|
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
|
2017-07-29 00:05:35 +00:00
|
|
|
# misc
|
2018-08-08 17:26:52 +00:00
|
|
|
asserts = callLibs ./asserts.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
debug = callLibs ./debug.nix;
|
|
|
|
misc = callLibs ./deprecated.nix;
|
2018-08-08 17:26:52 +00:00
|
|
|
|
2017-07-29 00:05:35 +00:00
|
|
|
# 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
|
2019-04-28 00:37:42 +00:00
|
|
|
platforms = systems.doubles;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
2019-09-18 08:34:02 +00:00
|
|
|
# linux kernel configuration
|
|
|
|
kernel = callLibs ./kernel.nix;
|
|
|
|
|
2018-05-11 15:12:15 +00:00
|
|
|
inherit (builtins) add addErrorContext attrNames concatLists
|
|
|
|
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;
|
2019-10-18 15:57:33 +00:00
|
|
|
inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
|
|
|
|
bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
|
2019-02-23 18:06:51 +00:00
|
|
|
importJSON warn info showWarnings nixpkgsVersion version mod compare
|
2018-08-08 17:26:52 +00:00
|
|
|
splitByAndCompare functionArgs setFunctionArgs isFunction;
|
2018-12-11 21:18:22 +00:00
|
|
|
inherit (fixedPoints) fix fix' converge extends composeExtensions
|
2017-09-29 13:10:48 +00:00
|
|
|
makeExtensible makeExtensibleWithCustomName;
|
2017-07-29 00:05:35 +00:00
|
|
|
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
2018-12-11 21:18:22 +00:00
|
|
|
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
2017-07-29 00:05:35 +00:00
|
|
|
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
|
|
|
mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
|
|
|
|
genAttrs isDerivation toDerivation optionalAttrs
|
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
|
|
|
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
2020-05-11 09:08:29 +00:00
|
|
|
getLib getDev getMan chooseDevOutputs zipWithNames zip
|
2019-09-11 11:03:48 +00:00
|
|
|
recurseIntoAttrs dontRecurseIntoAttrs;
|
2019-08-05 11:10:35 +00:00
|
|
|
inherit (lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
2017-07-29 00:05:35 +00:00
|
|
|
concatMap flatten remove findSingle findFirst any all count
|
|
|
|
optional optionals toList range partition zipListsWith zipLists
|
2018-05-11 15:12:15 +00:00
|
|
|
reverseList listDfs toposort sort naturalSort compareLists take
|
|
|
|
drop sublist last init crossLists unique intersectLists
|
2018-06-10 17:31:09 +00:00
|
|
|
subtractLists mutuallyExclusive groupBy groupBy';
|
2017-07-29 00:05:35 +00:00
|
|
|
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
|
|
|
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
2018-12-15 03:50:31 +00:00
|
|
|
makeLibraryPath makeBinPath optionalString
|
2019-02-04 08:09:38 +00:00
|
|
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
2018-05-11 15:12:15 +00:00
|
|
|
escapeShellArg escapeShellArgs replaceChars lowerChars
|
|
|
|
upperChars toLower toUpper addContextFrom splitString
|
2019-11-24 16:19:32 +00:00
|
|
|
removePrefix removeSuffix versionOlder versionAtLeast
|
|
|
|
getName getVersion
|
2018-05-11 15:12:15 +00:00
|
|
|
nameFromURL enableFeature enableFeatureAs withFeature
|
|
|
|
withFeatureAs fixedWidthString fixedWidthNumber isStorePath
|
2017-07-29 00:05:35 +00:00
|
|
|
toInt readPathsFromFile fileContents;
|
|
|
|
inherit (stringsWithDeps) textClosureList textClosureMap
|
|
|
|
noDepEntry fullDepEntry packEntry stringAfter;
|
|
|
|
inherit (customisation) overrideDerivation makeOverridable
|
2018-05-11 15:12:15 +00:00
|
|
|
callPackageWith callPackagesWith extendDerivation hydraJob
|
|
|
|
makeScope;
|
2017-07-29 00:05:35 +00:00
|
|
|
inherit (meta) addMetaAttrs dontDistribute setName updateName
|
2018-11-18 08:26:13 +00:00
|
|
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
2017-07-29 00:05:35 +00:00
|
|
|
hiPrioSet;
|
|
|
|
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
2018-05-11 15:12:15 +00:00
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
2020-01-19 23:44:07 +00:00
|
|
|
canCleanSource pathIsRegularFile pathIsGitRepo;
|
2020-01-02 21:09:31 +00:00
|
|
|
inherit (modules) evalModules unifyModuleSyntax
|
2019-12-05 02:29:51 +00:00
|
|
|
applyIfFunction mergeModules
|
2017-07-29 00:05:35 +00:00
|
|
|
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
|
2020-01-02 21:09:31 +00:00
|
|
|
mkAliasOptionModule doRename;
|
2017-07-29 00:05:35 +00:00
|
|
|
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;
|
2018-08-08 17:26:52 +00:00
|
|
|
inherit (asserts)
|
|
|
|
assertMsg assertOneOf;
|
2018-04-02 15:21:35 +00:00
|
|
|
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
2017-07-29 00:05:35 +00:00
|
|
|
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
2018-04-02 15:21:35 +00:00
|
|
|
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
|
|
|
|
traceShowValMarked showVal traceCall traceCall2 traceCall3
|
2018-05-11 15:12:15 +00:00
|
|
|
traceValIfNot runTests testAllTrue traceCallXml attrNamesToStr;
|
2017-07-29 00:05:35 +00:00
|
|
|
inherit (misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
|
|
|
maybeAttrNullable maybeAttr ifEnable checkFlag getValue
|
|
|
|
checkReqs uniqList uniqListExt condConcat lazyGenericClosure
|
|
|
|
innerModifySumArgs modifySumArgs innerClosePropagation
|
|
|
|
closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
|
|
|
|
mergeAttrsWithFunc mergeAttrsConcatenateValues
|
|
|
|
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
2018-07-26 10:05:40 +00:00
|
|
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
2020-05-11 22:04:41 +00:00
|
|
|
fakeHash fakeSha256 fakeSha512
|
2018-07-26 10:05:40 +00:00
|
|
|
nixType imap;
|
2019-09-24 08:47:34 +00:00
|
|
|
inherit (versions)
|
|
|
|
splitVersion;
|
2018-04-06 16:51:10 +00:00
|
|
|
});
|
2017-07-29 00:05:35 +00:00
|
|
|
in lib
|