at 23.11-beta 7.7 kB view raw
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.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 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 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 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 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 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 108 getName getVersion 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 142 getValues getFiles 143 optionAttrSetToDocList optionAttrSetToDocList' 144 scrubOptionValue literalExpression literalExample 145 showOption showOptionWithDefLocs showFiles 146 unknownModule mkOption mkPackageOption mkPackageOptionMD 147 mdDoc literalMD; 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 165 nixType imap; 166 inherit (self.versions) 167 splitVersion; 168 }); 169in lib