1/* Library of low-level helper functions for nix expressions.
2 *
3 * Please implement (mostly) exhaustive unit tests
4 * for new functions in `./tests.nix`.
5 */
6let
7
8 inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
9
10 lib = makeExtensible (self: let
11 callLibs = file: import file { lib = self; };
12 in {
13
14 # often used, or depending on very little
15 trivial = callLibs ./trivial.nix;
16 fixedPoints = callLibs ./fixed-points.nix;
17
18 # datatypes
19 attrsets = callLibs ./attrsets.nix;
20 lists = callLibs ./lists.nix;
21 strings = callLibs ./strings.nix;
22 stringsWithDeps = callLibs ./strings-with-deps.nix;
23
24 # packaging
25 customisation = callLibs ./customisation.nix;
26 derivations = callLibs ./derivations.nix;
27 maintainers = import ../maintainers/maintainer-list.nix;
28 teams = callLibs ../maintainers/team-list.nix;
29 meta = callLibs ./meta.nix;
30 versions = callLibs ./versions.nix;
31
32 # module system
33 modules = callLibs ./modules.nix;
34 options = callLibs ./options.nix;
35 types = callLibs ./types.nix;
36
37 # constants
38 licenses = callLibs ./licenses.nix;
39 sourceTypes = callLibs ./source-types.nix;
40 systems = callLibs ./systems;
41
42 # serialization
43 cli = callLibs ./cli.nix;
44 generators = callLibs ./generators.nix;
45
46 # misc
47 asserts = callLibs ./asserts.nix;
48 debug = callLibs ./debug.nix;
49 misc = callLibs ./deprecated.nix;
50
51 # domain-specific
52 fetchers = callLibs ./fetchers.nix;
53
54 # Eval-time filesystem handling
55 path = callLibs ./path;
56 filesystem = callLibs ./filesystem.nix;
57 sources = callLibs ./sources.nix;
58
59 # back-compat aliases
60 platforms = self.systems.doubles;
61
62 # linux kernel configuration
63 kernel = callLibs ./kernel.nix;
64
65 inherit (builtins) add addErrorContext attrNames concatLists
66 deepSeq elem elemAt filter genericClosure genList getAttr
67 hasAttr head isAttrs isBool isInt isList isPath isString length
68 lessThan listToAttrs pathExists readFile replaceStrings seq
69 stringLength sub substring tail trace;
70 inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor
71 bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
72 importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
73 info showWarnings nixpkgsVersion version isInOldestRelease
74 mod compare splitByAndCompare
75 functionArgs setFunctionArgs isFunction toFunction
76 toHexString toBaseDigits inPureEvalMode;
77 inherit (self.fixedPoints) fix fix' converge extends composeExtensions
78 composeManyExtensions makeExtensible makeExtensibleWithCustomName;
79 inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
80 getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
81 filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
82 mapAttrs' mapAttrsToList concatMapAttrs mapAttrsRecursive mapAttrsRecursiveCond
83 genAttrs isDerivation toDerivation optionalAttrs
84 zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
85 recursiveUpdate matchAttrs overrideExisting showAttrPath getOutput getBin
86 getLib getDev getMan chooseDevOutputs zipWithNames zip
87 recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets
88 updateManyAttrsByPath;
89 inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
90 concatMap flatten remove findSingle findFirst any all count
91 optional optionals toList range replicate partition zipListsWith zipLists
92 reverseList listDfs toposort sort naturalSort compareLists take
93 drop sublist last init crossLists unique intersectLists
94 subtractLists mutuallyExclusive groupBy groupBy';
95 inherit (self.strings) concatStrings concatMapStrings concatImapStrings
96 intersperse concatStringsSep concatMapStringsSep
97 concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
98 makeLibraryPath makeBinPath optionalString
99 hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
100 escapeShellArg escapeShellArgs
101 isStorePath isStringLike
102 isValidPosixName toShellVar toShellVars
103 escapeRegex escapeURL escapeXML replaceChars lowerChars
104 upperChars toLower toUpper addContextFrom splitString
105 removePrefix removeSuffix versionOlder versionAtLeast
106 getName getVersion
107 mesonOption mesonBool mesonEnable
108 nameFromURL enableFeature enableFeatureAs withFeature
109 withFeatureAs fixedWidthString fixedWidthNumber
110 toInt toIntBase10 readPathsFromFile fileContents;
111 inherit (self.stringsWithDeps) textClosureList textClosureMap
112 noDepEntry fullDepEntry packEntry stringAfter;
113 inherit (self.customisation) overrideDerivation makeOverridable
114 callPackageWith callPackagesWith extendDerivation hydraJob
115 makeScope makeScopeWithSplicing;
116 inherit (self.derivations) lazyDerivation;
117 inherit (self.meta) addMetaAttrs dontDistribute setName updateName
118 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
119 hiPrioSet getLicenseFromSpdxId getExe;
120 inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile;
121 inherit (self.sources) cleanSourceFilter
122 cleanSource sourceByRegex sourceFilesBySuffices
123 commitIdFromGitRepo cleanSourceWith pathHasContext
124 canCleanSource pathIsGitRepo;
125 inherit (self.modules) evalModules setDefaultModuleLocation
126 unifyModuleSyntax applyModuleArgsIfFunction mergeModules
127 mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
128 pushDownProperties dischargeProperties filterOverrides
129 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
130 mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
131 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
132 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
133 mkRenamedOptionModule mkRenamedOptionModuleWith
134 mkMergedOptionModule mkChangedOptionModule
135 mkAliasOptionModule mkDerivedConfig doRename
136 mkAliasOptionModuleMD;
137 inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
138 mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
139 getValues getFiles
140 optionAttrSetToDocList optionAttrSetToDocList'
141 scrubOptionValue literalExpression literalExample literalDocBook
142 showOption showOptionWithDefLocs showFiles
143 unknownModule mkOption mkPackageOption mkPackageOptionMD
144 mdDoc literalMD;
145 inherit (self.types) isType setType defaultTypeMerge defaultFunctor
146 isOptionType mkOptionType;
147 inherit (self.asserts)
148 assertMsg assertOneOf;
149 inherit (self.debug) traceIf traceVal traceValFn
150 traceSeq traceSeqN traceValSeq
151 traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
152 runTests testAllTrue;
153 inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
154 maybeAttrNullable maybeAttr ifEnable checkFlag getValue
155 checkReqs uniqList uniqListExt condConcat lazyGenericClosure
156 innerModifySumArgs modifySumArgs innerClosePropagation
157 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
158 mergeAttrsWithFunc mergeAttrsConcatenateValues
159 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
160 mergeAttrsByFuncDefaultsClean mergeAttrBy
161 fakeHash fakeSha256 fakeSha512
162 nixType imap;
163 inherit (self.versions)
164 splitVersion;
165 });
166in lib