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/misc.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 xor 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 mirrorFunctionArgs
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 mergeAttrsList overrideExisting showAttrPath getOutput
88 getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
89 recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
90 mapCartesianProduct updateManyAttrsByPath;
91 inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
92 ifilter0 concatMap flatten remove findSingle findFirst any all count
93 optional optionals toList range replicate partition zipListsWith zipLists
94 reverseList listDfs toposort sort sortOn naturalSort compareLists take
95 drop sublist last init crossLists unique allUnique intersectLists
96 subtractLists mutuallyExclusive groupBy groupBy';
97 inherit (self.strings) concatStrings concatMapStrings concatImapStrings
98 intersperse concatStringsSep concatMapStringsSep
99 concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
100 makeLibraryPath makeIncludePath 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 optionalDrvAttr;
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 packagesFromDirectoryRecursive;
125 inherit (self.sources) cleanSourceFilter
126 cleanSource sourceByRegex sourceFilesBySuffices
127 commitIdFromGitRepo cleanSourceWith pathHasContext
128 canCleanSource pathIsGitRepo;
129 inherit (self.modules) evalModules setDefaultModuleLocation
130 unifyModuleSyntax applyModuleArgsIfFunction mergeModules
131 mergeModules' mergeOptionDecls mergeDefinitions
132 pushDownProperties dischargeProperties filterOverrides
133 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
134 mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
135 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
136 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
137 mkRenamedOptionModule mkRenamedOptionModuleWith
138 mkMergedOptionModule mkChangedOptionModule
139 mkAliasOptionModule mkDerivedConfig doRename
140 mkAliasOptionModuleMD;
141 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;
142 inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
143 mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
145 optionAttrSetToDocList optionAttrSetToDocList'
146 scrubOptionValue literalExpression literalExample
147 showOption showOptionWithDefLocs showFiles
148 unknownModule mkOption mkPackageOption mkPackageOptionMD
150 inherit (self.types) isType setType defaultTypeMerge defaultFunctor
151 isOptionType mkOptionType;
152 inherit (self.asserts)
153 assertMsg assertOneOf;
154 inherit (self.debug) traceIf traceVal traceValFn
155 traceSeq traceSeqN traceValSeq
156 traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
157 runTests testAllTrue;
158 inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
159 maybeAttrNullable maybeAttr ifEnable checkFlag getValue
160 checkReqs uniqList uniqListExt condConcat lazyGenericClosure
161 innerModifySumArgs modifySumArgs innerClosePropagation
162 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
163 mergeAttrsWithFunc mergeAttrsConcatenateValues
164 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
165 mergeAttrsByFuncDefaultsClean mergeAttrBy
166 fakeHash fakeSha256 fakeSha512
168 inherit (self.versions)