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;
68 network = callLibs ./network;
70 # TODO: For consistency, all builtins should also be available from a sub-library;
71 # these are the only ones that are currently not
72 inherit (builtins) addErrorContext isPath trace typeOf unsafeGetAttrPos;
73 inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
74 bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
75 importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
76 info showWarnings nixpkgsVersion version isInOldestRelease oldestSupportedReleaseIsAtLeast
77 mod compare splitByAndCompare seq deepSeq lessThan add sub
78 functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
79 fromHexString toHexString toBaseDigits inPureEvalMode isBool isInt pathExists
80 genericClosure readFile;
81 inherit (self.fixedPoints) fix fix' converge extends composeExtensions
82 composeManyExtensions makeExtensible makeExtensibleWithCustomName
84 inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
85 getAttrFromPath attrVals attrNames attrValues getAttrs catAttrs filterAttrs
86 filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
87 mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
88 mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
89 zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
90 recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput getFirstOutput
91 getBin getLib getStatic getDev getInclude getMan chooseDevOutputs zipWithNames zip
92 recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
93 mapCartesianProduct updateManyAttrsByPath listToAttrs hasAttr getAttr isAttrs intersectAttrs removeAttrs;
94 inherit (self.lists) singleton forEach map foldr fold foldl foldl' imap0 imap1
95 filter ifilter0 concatMap flatten remove findSingle findFirst any all count
96 optional optionals toList range replicate partition zipListsWith zipLists
97 reverseList listDfs toposort sort sortOn naturalSort compareLists take
98 drop sublist last init crossLists unique allUnique intersectLists
99 subtractLists mutuallyExclusive groupBy groupBy' concatLists genList
100 length head tail elem elemAt isList;
101 inherit (self.strings) concatStrings concatMapStrings concatImapStrings
102 stringLength substring isString replaceStrings
103 intersperse concatStringsSep concatMapStringsSep
104 concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
105 makeLibraryPath makeIncludePath makeBinPath optionalString
106 hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
107 escapeShellArg escapeShellArgs
108 isStorePath isStringLike
109 isValidPosixName toShellVar toShellVars trim trimWith
110 escapeRegex escapeURL escapeXML replaceChars lowerChars
111 upperChars toLower toUpper addContextFrom splitString
112 removePrefix removeSuffix versionOlder versionAtLeast
113 getName getVersion match split
114 cmakeOptionType cmakeBool cmakeFeature
115 mesonOption mesonBool mesonEnable
116 nameFromURL enableFeature enableFeatureAs withFeature
117 withFeatureAs fixedWidthString fixedWidthNumber
118 toInt toIntBase10 readPathsFromFile fileContents;
119 inherit (self.stringsWithDeps) textClosureList textClosureMap
120 noDepEntry fullDepEntry packEntry stringAfter;
121 inherit (self.customisation) overrideDerivation makeOverridable
122 callPackageWith callPackagesWith extendDerivation hydraJob
123 makeScope makeScopeWithSplicing makeScopeWithSplicing';
124 inherit (self.derivations) lazyDerivation optionalDrvAttr;
125 inherit (self.meta) addMetaAttrs dontDistribute setName updateName
126 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
127 hiPrioSet licensesSpdx getLicenseFromSpdxId getLicenseFromSpdxIdOr
129 inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
130 packagesFromDirectoryRecursive;
131 inherit (self.sources) cleanSourceFilter
132 cleanSource sourceByRegex sourceFilesBySuffices
133 commitIdFromGitRepo cleanSourceWith pathHasContext
134 canCleanSource pathIsGitRepo;
135 inherit (self.modules) evalModules setDefaultModuleLocation
136 unifyModuleSyntax applyModuleArgsIfFunction mergeModules
137 mergeModules' mergeOptionDecls mergeDefinitions
138 pushDownProperties dischargeProperties filterOverrides
139 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
140 mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
141 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
142 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
143 mkRenamedOptionModule mkRenamedOptionModuleWith
144 mkMergedOptionModule mkChangedOptionModule
145 mkAliasOptionModule mkDerivedConfig doRename
146 mkAliasOptionModuleMD;
147 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;
148 inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
149 mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
151 optionAttrSetToDocList optionAttrSetToDocList'
152 scrubOptionValue literalExpression literalExample
153 showOption showOptionWithDefLocs showFiles
154 unknownModule mkOption mkPackageOption mkPackageOptionMD
156 inherit (self.types) isType setType defaultTypeMerge defaultFunctor
157 isOptionType mkOptionType;
158 inherit (self.asserts)
159 assertMsg assertOneOf;
160 inherit (self.debug) traceIf traceVal traceValFn
161 traceSeq traceSeqN traceValSeq
162 traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
163 runTests testAllTrue;
164 inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
165 maybeAttrNullable maybeAttr ifEnable checkFlag getValue
166 checkReqs uniqList uniqListExt condConcat lazyGenericClosure
167 innerModifySumArgs modifySumArgs innerClosePropagation
168 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
169 mergeAttrsWithFunc mergeAttrsConcatenateValues
170 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
171 mergeAttrsByFuncDefaultsClean mergeAttrBy
172 fakeHash fakeSha256 fakeSha512
174 inherit (self.versions)