2020-04-24 23:36:52 +00:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
|
|
|
* for new functions in `./tests.nix'.
|
|
|
|
*/
|
|
|
|
let
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
lib = makeExtensible (self: let
|
|
|
|
callLibs = file: import file { lib = self; };
|
2020-10-27 00:29:36 +00:00
|
|
|
in {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# often used, or depending on very little
|
|
|
|
trivial = callLibs ./trivial.nix;
|
|
|
|
fixedPoints = callLibs ./fixed-points.nix;
|
|
|
|
|
|
|
|
# datatypes
|
|
|
|
attrsets = callLibs ./attrsets.nix;
|
|
|
|
lists = callLibs ./lists.nix;
|
|
|
|
strings = callLibs ./strings.nix;
|
|
|
|
stringsWithDeps = callLibs ./strings-with-deps.nix;
|
|
|
|
|
|
|
|
# packaging
|
|
|
|
customisation = callLibs ./customisation.nix;
|
|
|
|
maintainers = import ../maintainers/maintainer-list.nix;
|
|
|
|
teams = callLibs ../maintainers/team-list.nix;
|
|
|
|
meta = callLibs ./meta.nix;
|
|
|
|
sources = callLibs ./sources.nix;
|
|
|
|
versions = callLibs ./versions.nix;
|
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
|
|
|
# serialization
|
|
|
|
cli = callLibs ./cli.nix;
|
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
|
|
|
|
# misc
|
|
|
|
asserts = callLibs ./asserts.nix;
|
|
|
|
debug = callLibs ./debug.nix;
|
|
|
|
misc = callLibs ./deprecated.nix;
|
|
|
|
|
|
|
|
# domain-specific
|
|
|
|
fetchers = callLibs ./fetchers.nix;
|
|
|
|
|
|
|
|
# Eval-time filesystem handling
|
|
|
|
filesystem = callLibs ./filesystem.nix;
|
|
|
|
|
|
|
|
# back-compat aliases
|
2020-10-27 00:29:36 +00:00
|
|
|
platforms = self.systems.doubles;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# linux kernel configuration
|
|
|
|
kernel = callLibs ./kernel.nix;
|
|
|
|
|
|
|
|
inherit (builtins) add addErrorContext attrNames concatLists
|
|
|
|
deepSeq elem elemAt filter genericClosure genList getAttr
|
|
|
|
hasAttr head isAttrs isBool isInt isList isString length
|
|
|
|
lessThan listToAttrs pathExists readFile replaceStrings seq
|
2020-10-27 00:29:36 +00:00
|
|
|
stringLength sub substring tail trace;
|
|
|
|
inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor
|
|
|
|
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
2022-01-13 20:06:32 +00:00
|
|
|
importJSON importTOML warn warnIf throwIfNot checkListOfEnum
|
2022-01-07 04:07:37 +00:00
|
|
|
info showWarnings nixpkgsVersion version
|
2021-05-03 20:48:10 +00:00
|
|
|
mod compare splitByAndCompare functionArgs setFunctionArgs isFunction
|
|
|
|
toHexString toBaseDigits;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
2020-11-15 13:44:38 +00:00
|
|
|
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
2020-04-24 23:36:52 +00:00
|
|
|
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
|
|
|
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
|
|
|
mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
|
|
|
|
genAttrs isDerivation toDerivation optionalAttrs
|
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
|
|
|
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
2020-07-18 16:06:22 +00:00
|
|
|
getLib getDev getMan chooseDevOutputs zipWithNames zip
|
2021-02-05 17:12:51 +00:00
|
|
|
recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
2020-04-24 23:36:52 +00:00
|
|
|
concatMap flatten remove findSingle findFirst any all count
|
|
|
|
optional optionals toList range partition zipListsWith zipLists
|
|
|
|
reverseList listDfs toposort sort naturalSort compareLists take
|
|
|
|
drop sublist last init crossLists unique intersectLists
|
|
|
|
subtractLists mutuallyExclusive groupBy groupBy';
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
2020-04-24 23:36:52 +00:00
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
|
|
|
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
|
|
|
makeLibraryPath makeBinPath optionalString
|
|
|
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
2021-10-04 12:37:57 +00:00
|
|
|
escapeShellArg escapeShellArgs escapeRegex escapeXML replaceChars lowerChars
|
2020-04-24 23:36:52 +00:00
|
|
|
upperChars toLower toUpper addContextFrom splitString
|
|
|
|
removePrefix removeSuffix versionOlder versionAtLeast
|
|
|
|
getName getVersion
|
|
|
|
nameFromURL enableFeature enableFeatureAs withFeature
|
|
|
|
withFeatureAs fixedWidthString fixedWidthNumber isStorePath
|
|
|
|
toInt readPathsFromFile fileContents;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.stringsWithDeps) textClosureList textClosureMap
|
2020-04-24 23:36:52 +00:00
|
|
|
noDepEntry fullDepEntry packEntry stringAfter;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.customisation) overrideDerivation makeOverridable
|
2020-04-24 23:36:52 +00:00
|
|
|
callPackageWith callPackagesWith extendDerivation hydraJob
|
2020-11-21 19:51:51 +00:00
|
|
|
makeScope makeScopeWithSplicing;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
2020-04-24 23:36:52 +00:00
|
|
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
2021-12-19 01:06:50 +00:00
|
|
|
hiPrioSet getLicenseFromSpdxId;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.sources) pathType pathIsDirectory cleanSourceFilter
|
2020-04-24 23:36:52 +00:00
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
|
|
|
canCleanSource pathIsRegularFile pathIsGitRepo;
|
2022-02-10 20:34:41 +00:00
|
|
|
inherit (self.modules) evalModules setDefaultModuleLocation
|
|
|
|
unifyModuleSyntax applyIfFunction mergeModules
|
2020-04-24 23:36:52 +00:00
|
|
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
|
|
|
pushDownProperties dischargeProperties filterOverrides
|
|
|
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
2021-08-18 13:19:15 +00:00
|
|
|
mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
|
2021-07-14 22:03:04 +00:00
|
|
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
2020-04-24 23:36:52 +00:00
|
|
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
|
|
|
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
2021-12-06 16:07:01 +00:00
|
|
|
mkAliasOptionModule mkDerivedConfig doRename;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
2022-01-26 04:04:25 +00:00
|
|
|
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
|
|
|
|
getValues getFiles
|
|
|
|
optionAttrSetToDocList optionAttrSetToDocList'
|
2021-10-06 13:57:05 +00:00
|
|
|
scrubOptionValue literalExpression literalExample literalDocBook
|
2022-03-05 16:20:37 +00:00
|
|
|
showOption showFiles unknownModule mkOption mkPackageOption;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
2020-04-24 23:36:52 +00:00
|
|
|
isOptionType mkOptionType;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.asserts)
|
2020-04-24 23:36:52 +00:00
|
|
|
assertMsg assertOneOf;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
2020-04-24 23:36:52 +00:00
|
|
|
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
2021-02-05 17:12:51 +00:00
|
|
|
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN traceShowVal
|
2020-04-24 23:36:52 +00:00
|
|
|
traceShowValMarked showVal traceCall traceCall2 traceCall3
|
|
|
|
traceValIfNot runTests testAllTrue traceCallXml attrNamesToStr;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
2020-04-24 23:36:52 +00:00
|
|
|
maybeAttrNullable maybeAttr ifEnable checkFlag getValue
|
|
|
|
checkReqs uniqList uniqListExt condConcat lazyGenericClosure
|
|
|
|
innerModifySumArgs modifySumArgs innerClosePropagation
|
|
|
|
closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
|
|
|
|
mergeAttrsWithFunc mergeAttrsConcatenateValues
|
|
|
|
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
|
|
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
2020-05-15 21:57:56 +00:00
|
|
|
fakeHash fakeSha256 fakeSha512
|
2020-04-24 23:36:52 +00:00
|
|
|
nixType imap;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.versions)
|
2020-04-24 23:36:52 +00:00
|
|
|
splitVersion;
|
|
|
|
});
|
|
|
|
in lib
|