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 callLibs = file: import file { inherit lib; };
9
10 lib = rec {
11
12 # often used, or depending on very little
13 trivial = callLibs ./trivial.nix;
14 fixedPoints = callLibs ./fixed-points.nix;
15
16 # datatypes
17 attrsets = callLibs ./attrsets.nix;
18 lists = callLibs ./lists.nix;
19 strings = callLibs ./strings.nix;
20 stringsWithDeps = callLibs ./strings-with-deps.nix;
21
22 # packaging
23 customisation = callLibs ./customisation.nix;
24 maintainers = import ./maintainers-list.nix;
25 meta = callLibs ./meta.nix;
26 sources = callLibs ./sources.nix;
27 versions = callLibs ./versions.nix;
28
29 # module system
30 modules = callLibs ./modules.nix;
31 options = callLibs ./options.nix;
32 types = callLibs ./types.nix;
33
34 # constants
35 licenses = callLibs ./licenses.nix;
36 systems = callLibs ./systems;
37
38 # misc
39 debug = callLibs ./debug.nix;
40
41 generators = callLibs ./generators.nix;
42 misc = callLibs ./deprecated.nix;
43 # domain-specific
44 fetchers = callLibs ./fetchers.nix;
45
46 # Eval-time filesystem handling
47 filesystem = callLibs ./filesystem.nix;
48
49 # back-compat aliases
50 platforms = systems.doubles;
51
52 inherit (builtins) add addErrorContext attrNames
53 concatLists deepSeq elem elemAt filter genericClosure genList
54 getAttr hasAttr head isAttrs isBool isInt isList
55 isString length lessThan listToAttrs pathExists readFile
56 replaceStrings seq stringLength sub substring tail;
57 inherit (trivial) id const concat or and boolToString mergeAttrs
58 flip mapNullable inNixShell min max importJSON warn info
59 nixpkgsVersion mod compare splitByAndCompare
60 functionArgs setFunctionArgs isFunction;
61
62 inherit (fixedPoints) fix fix' extends composeExtensions
63 makeExtensible makeExtensibleWithCustomName;
64 inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
65 getAttrFromPath attrVals attrValues catAttrs filterAttrs
66 filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
67 mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
68 genAttrs isDerivation toDerivation optionalAttrs
69 zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
70 recursiveUpdate matchAttrs overrideExisting getOutput getBin
71 getLib getDev chooseDevOutputs zipWithNames zip;
72 inherit (lists) singleton foldr fold foldl foldl' imap0 imap1
73 concatMap flatten remove findSingle findFirst any all count
74 optional optionals toList range partition zipListsWith zipLists
75 reverseList listDfs toposort sort compareLists take drop sublist
76 last init crossLists unique intersectLists subtractLists
77 mutuallyExclusive;
78 inherit (strings) concatStrings concatMapStrings concatImapStrings
79 intersperse concatStringsSep concatMapStringsSep
80 concatImapStringsSep makeSearchPath makeSearchPathOutput
81 makeLibraryPath makeBinPath makePerlPath optionalString
82 hasPrefix hasSuffix stringToCharacters stringAsChars escape
83 escapeShellArg escapeShellArgs replaceChars lowerChars upperChars
84 toLower toUpper addContextFrom splitString removePrefix
85 removeSuffix versionOlder versionAtLeast getVersion nameFromURL
86 enableFeature fixedWidthString fixedWidthNumber isStorePath
87 toInt readPathsFromFile fileContents;
88 inherit (stringsWithDeps) textClosureList textClosureMap
89 noDepEntry fullDepEntry packEntry stringAfter;
90 inherit (customisation) overrideDerivation makeOverridable
91 callPackageWith callPackagesWith extendDerivation
92 hydraJob makeScope;
93 inherit (meta) addMetaAttrs dontDistribute setName updateName
94 appendToName mapDerivationAttrset lowPrio lowPrioSet hiPrio
95 hiPrioSet;
96 inherit (sources) pathType pathIsDirectory cleanSourceFilter
97 cleanSource sourceByRegex sourceFilesBySuffices
98 commitIdFromGitRepo cleanSourceWith pathHasContext canCleanSource;
99 inherit (modules) evalModules closeModules unifyModuleSyntax
100 applyIfFunction unpackSubmodule packSubmodule mergeModules
101 mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
102 pushDownProperties dischargeProperties filterOverrides
103 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
104 mkOptionDefault mkDefault mkForce mkVMOverride mkStrict
105 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
106 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
107 mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
108 mkAliasOptionModule doRename filterModules;
109 inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
110 mergeDefaultOption mergeOneOption mergeEqualOption getValues
111 getFiles optionAttrSetToDocList optionAttrSetToDocList'
112 scrubOptionValue literalExample showOption showFiles
113 unknownModule mkOption;
114 inherit (types) isType setType defaultTypeMerge defaultFunctor
115 isOptionType mkOptionType;
116 inherit (debug) addErrorContextToAttrs traceIf traceVal
117 traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
118 traceValSeqN traceShowVal traceShowValMarked
119 showVal traceCall traceCall2 traceCall3 traceValIfNot runTests
120 testAllTrue strict traceCallXml attrNamesToStr;
121 inherit (misc) maybeEnv defaultMergeArg defaultMerge foldArgs
122 defaultOverridableDelayableArgs composedArgsAndFun
123 maybeAttrNullable maybeAttr ifEnable checkFlag getValue
124 checkReqs uniqList uniqListExt condConcat lazyGenericClosure
125 innerModifySumArgs modifySumArgs innerClosePropagation
126 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
127 mergeAttrsWithFunc mergeAttrsConcatenateValues
128 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
129 mergeAttrsByFuncDefaultsClean mergeAttrBy
130 prepareDerivationArgs nixType imap overridableDelayableArgs;
131 };
132in lib