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 gvariant = callLibs ./gvariant.nix;
45 generators = callLibs ./generators.nix;
46
47 # misc
48 asserts = callLibs ./asserts.nix;
49 debug = callLibs ./debug.nix;
50 misc = callLibs ./deprecated/misc.nix;
51
52 # domain-specific
53 fetchers = callLibs ./fetchers.nix;
54
55 # Eval-time filesystem handling
56 path = callLibs ./path;
57 filesystem = callLibs ./filesystem.nix;
58 fileset = callLibs ./fileset;
59 sources = callLibs ./sources.nix;
60
61 # back-compat aliases
62 platforms = self.systems.doubles;
63
64 # linux kernel configuration
65 kernel = callLibs ./kernel.nix;
66
67 # TODO: For consistency, all builtins should also be available from a sub-library;
68 # these are the only ones that are currently not
69 inherit (builtins) addErrorContext isPath trace;
70 inherit (self.trivial) id const pipe concat or and xor 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 seq deepSeq lessThan add sub
75 functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
76 toHexString toBaseDigits inPureEvalMode isBool isInt pathExists
77 genericClosure readFile;
78 inherit (self.fixedPoints) fix fix' converge extends composeExtensions
79 composeManyExtensions makeExtensible makeExtensibleWithCustomName;
80 inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
81 getAttrFromPath attrVals attrNames attrValues getAttrs catAttrs filterAttrs
82 filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
83 mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
84 mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
85 zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
86 recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
87 getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
88 recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
89 mapCartesianProduct updateManyAttrsByPath listToAttrs hasAttr getAttr isAttrs intersectAttrs removeAttrs;
90 inherit (self.lists) singleton forEach map foldr fold foldl foldl' imap0 imap1
91 filter ifilter0 concatMap flatten remove findSingle findFirst any all count
92 optional optionals toList range replicate partition zipListsWith zipLists
93 reverseList listDfs toposort sort sortOn naturalSort compareLists take
94 drop sublist last init crossLists unique allUnique intersectLists
95 subtractLists mutuallyExclusive groupBy groupBy' concatLists genList
96 length head tail elem elemAt isList;
97 inherit (self.strings) concatStrings concatMapStrings concatImapStrings
98 stringLength substring isString replaceStrings
99 intersperse concatStringsSep concatMapStringsSep
100 concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
101 makeLibraryPath makeIncludePath makeBinPath optionalString
102 hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
103 escapeShellArg escapeShellArgs
104 isStorePath isStringLike
105 isValidPosixName toShellVar toShellVars trim trimWith
106 escapeRegex escapeURL escapeXML replaceChars lowerChars
107 upperChars toLower toUpper addContextFrom splitString
108 removePrefix removeSuffix versionOlder versionAtLeast
109 getName getVersion match split
110 cmakeOptionType cmakeBool cmakeFeature
111 mesonOption mesonBool mesonEnable
112 nameFromURL enableFeature enableFeatureAs withFeature
113 withFeatureAs fixedWidthString fixedWidthNumber
114 toInt toIntBase10 readPathsFromFile fileContents;
115 inherit (self.stringsWithDeps) textClosureList textClosureMap
116 noDepEntry fullDepEntry packEntry stringAfter;
117 inherit (self.customisation) overrideDerivation makeOverridable
118 callPackageWith callPackagesWith extendDerivation hydraJob
119 makeScope makeScopeWithSplicing makeScopeWithSplicing';
120 inherit (self.derivations) lazyDerivation optionalDrvAttr;
121 inherit (self.meta) addMetaAttrs dontDistribute setName updateName
122 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
123 hiPrioSet getLicenseFromSpdxId getExe getExe';
124 inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
125 packagesFromDirectoryRecursive;
126 inherit (self.sources) cleanSourceFilter
127 cleanSource sourceByRegex sourceFilesBySuffices
128 commitIdFromGitRepo cleanSourceWith pathHasContext
129 canCleanSource pathIsGitRepo;
130 inherit (self.modules) evalModules setDefaultModuleLocation
131 unifyModuleSyntax applyModuleArgsIfFunction mergeModules
132 mergeModules' mergeOptionDecls mergeDefinitions
133 pushDownProperties dischargeProperties filterOverrides
134 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
135 mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
136 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
137 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
138 mkRenamedOptionModule mkRenamedOptionModuleWith
139 mkMergedOptionModule mkChangedOptionModule
140 mkAliasOptionModule mkDerivedConfig doRename
141 mkAliasOptionModuleMD;
142 evalOptionValue = lib.warn "External use of `lib.evalOptionValue` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/." self.modules.evalOptionValue;
143 inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
144 mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
145 getValues getFiles
146 optionAttrSetToDocList optionAttrSetToDocList'
147 scrubOptionValue literalExpression literalExample
148 showOption showOptionWithDefLocs showFiles
149 unknownModule mkOption mkPackageOption mkPackageOptionMD
150 mdDoc literalMD;
151 inherit (self.types) isType setType defaultTypeMerge defaultFunctor
152 isOptionType mkOptionType;
153 inherit (self.asserts)
154 assertMsg assertOneOf;
155 inherit (self.debug) traceIf traceVal traceValFn
156 traceSeq traceSeqN traceValSeq
157 traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
158 runTests testAllTrue;
159 inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
160 maybeAttrNullable maybeAttr ifEnable checkFlag getValue
161 checkReqs uniqList uniqListExt condConcat lazyGenericClosure
162 innerModifySumArgs modifySumArgs innerClosePropagation
163 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
164 mergeAttrsWithFunc mergeAttrsConcatenateValues
165 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
166 mergeAttrsByFuncDefaultsClean mergeAttrBy
167 fakeHash fakeSha256 fakeSha512
168 nixType imap;
169 inherit (self.versions)
170 splitVersion;
171 });
172in lib