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