Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at github-to-sqlite-beautifulsoup4 168 lines 7.6 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 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 concatMapAttrs mapAttrsRecursive mapAttrsRecursiveCond 85 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 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 mesonOption mesonBool mesonEnable 110 nameFromURL enableFeature enableFeatureAs withFeature 111 withFeatureAs fixedWidthString fixedWidthNumber 112 toInt toIntBase10 readPathsFromFile fileContents; 113 inherit (self.stringsWithDeps) textClosureList textClosureMap 114 noDepEntry fullDepEntry packEntry stringAfter; 115 inherit (self.customisation) overrideDerivation makeOverridable 116 callPackageWith callPackagesWith extendDerivation hydraJob 117 makeScope makeScopeWithSplicing makeScopeWithSplicing'; 118 inherit (self.derivations) lazyDerivation; 119 inherit (self.meta) addMetaAttrs dontDistribute setName updateName 120 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio 121 hiPrioSet getLicenseFromSpdxId getExe getExe'; 122 inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile; 123 inherit (self.sources) cleanSourceFilter 124 cleanSource sourceByRegex sourceFilesBySuffices 125 commitIdFromGitRepo cleanSourceWith pathHasContext 126 canCleanSource pathIsGitRepo; 127 inherit (self.modules) evalModules setDefaultModuleLocation 128 unifyModuleSyntax applyModuleArgsIfFunction mergeModules 129 mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions 130 pushDownProperties dischargeProperties filterOverrides 131 sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride 132 mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride 133 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions 134 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule 135 mkRenamedOptionModule mkRenamedOptionModuleWith 136 mkMergedOptionModule mkChangedOptionModule 137 mkAliasOptionModule mkDerivedConfig doRename 138 mkAliasOptionModuleMD; 139 inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions 140 mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption 141 getValues getFiles 142 optionAttrSetToDocList optionAttrSetToDocList' 143 scrubOptionValue literalExpression literalExample 144 showOption showOptionWithDefLocs showFiles 145 unknownModule mkOption mkPackageOption mkPackageOptionMD 146 mdDoc literalMD; 147 inherit (self.types) isType setType defaultTypeMerge defaultFunctor 148 isOptionType mkOptionType; 149 inherit (self.asserts) 150 assertMsg assertOneOf; 151 inherit (self.debug) traceIf traceVal traceValFn 152 traceSeq traceSeqN traceValSeq 153 traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN 154 runTests testAllTrue; 155 inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs 156 maybeAttrNullable maybeAttr ifEnable checkFlag getValue 157 checkReqs uniqList uniqListExt condConcat lazyGenericClosure 158 innerModifySumArgs modifySumArgs innerClosePropagation 159 closePropagation mapAttrsFlatten nvs setAttr setAttrMerge 160 mergeAttrsWithFunc mergeAttrsConcatenateValues 161 mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults 162 mergeAttrsByFuncDefaultsClean mergeAttrBy 163 fakeHash fakeSha256 fakeSha512 164 nixType imap; 165 inherit (self.versions) 166 splitVersion; 167 }); 168in lib