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