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