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