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