2017-03-30 20:03:40 +00:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
2023-01-01 21:51:54 +00:00
|
|
|
* for new functions in `./tests.nix`.
|
2017-03-30 20:03:40 +00:00
|
|
|
*/
|
2016-09-14 23:21:42 +00:00
|
|
|
let
|
2006-09-25 10:07:59 +00:00
|
|
|
|
2020-11-11 02:36:19 +00:00
|
|
|
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
2018-04-06 16:51:10 +00:00
|
|
|
lib = makeExtensible (self: let
|
|
|
|
callLibs = file: import file { lib = self; };
|
2020-10-20 11:47:24 +00:00
|
|
|
in {
|
2017-07-29 00:05:35 +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;
|
2022-06-25 11:53:02 +00:00
|
|
|
derivations = callLibs ./derivations.nix;
|
2018-03-04 03:09:35 +00:00
|
|
|
maintainers = import ../maintainers/maintainer-list.nix;
|
2019-10-27 21:44:24 +00:00
|
|
|
teams = callLibs ../maintainers/team-list.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
meta = callLibs ./meta.nix;
|
2018-03-03 04:26:32 +00:00
|
|
|
versions = callLibs ./versions.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
2022-02-20 19:23:12 +00:00
|
|
|
sourceTypes = callLibs ./source-types.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
2020-01-22 22:22:23 +00:00
|
|
|
# serialization
|
|
|
|
cli = callLibs ./cli.nix;
|
2023-06-14 08:14:23 +00:00
|
|
|
gvariant = callLibs ./gvariant.nix;
|
2020-01-22 22:22:23 +00:00
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
|
2017-07-29 00:05:35 +00:00
|
|
|
# misc
|
2018-08-08 17:26:52 +00:00
|
|
|
asserts = callLibs ./asserts.nix;
|
2017-07-29 00:05:35 +00:00
|
|
|
debug = callLibs ./debug.nix;
|
|
|
|
misc = callLibs ./deprecated.nix;
|
2018-08-08 17:26:52 +00:00
|
|
|
|
2017-07-29 00:05:35 +00:00
|
|
|
# domain-specific
|
|
|
|
fetchers = callLibs ./fetchers.nix;
|
|
|
|
|
|
|
|
# Eval-time filesystem handling
|
2022-12-23 20:04:14 +00:00
|
|
|
path = callLibs ./path;
|
2017-07-29 00:05:35 +00:00
|
|
|
filesystem = callLibs ./filesystem.nix;
|
2023-08-16 22:55:32 +00:00
|
|
|
fileset = callLibs ./fileset;
|
2022-12-23 20:04:14 +00:00
|
|
|
sources = callLibs ./sources.nix;
|
2017-02-09 02:27:22 +00:00
|
|
|
|
|
|
|
# back-compat aliases
|
2020-10-20 11:47:24 +00:00
|
|
|
platforms = self.systems.doubles;
|
2017-07-29 00:05:35 +00:00
|
|
|
|
2019-09-18 08:34:02 +00:00
|
|
|
# linux kernel configuration
|
|
|
|
kernel = callLibs ./kernel.nix;
|
|
|
|
|
2018-05-11 15:12:15 +00:00
|
|
|
inherit (builtins) add addErrorContext attrNames concatLists
|
|
|
|
deepSeq elem elemAt filter genericClosure genList getAttr
|
2022-12-30 23:53:24 +00:00
|
|
|
hasAttr head isAttrs isBool isInt isList isPath isString length
|
2018-05-11 15:12:15 +00:00
|
|
|
lessThan listToAttrs pathExists readFile replaceStrings seq
|
2020-10-20 14:34:15 +00:00
|
|
|
stringLength sub substring tail trace;
|
2024-04-04 14:05:18 +00:00
|
|
|
inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
|
2020-10-20 13:24:59 +00:00
|
|
|
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
2022-03-27 14:48:33 +00:00
|
|
|
importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
|
2022-03-09 13:41:43 +00:00
|
|
|
info showWarnings nixpkgsVersion version isInOldestRelease
|
2022-03-21 22:06:01 +00:00
|
|
|
mod compare splitByAndCompare
|
2023-05-28 21:51:52 +00:00
|
|
|
functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
|
2021-11-14 23:14:09 +00:00
|
|
|
toHexString toBaseDigits inPureEvalMode;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
2020-11-11 02:36:19 +00:00
|
|
|
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
2018-12-11 21:18:22 +00:00
|
|
|
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
2023-02-28 10:04:19 +00:00
|
|
|
filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
|
2023-09-10 15:56:29 +00:00
|
|
|
mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
|
|
|
|
mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
|
2017-07-29 00:05:35 +00:00
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
2024-02-26 14:47:57 +00:00
|
|
|
recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
|
|
|
|
getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
|
2021-11-22 19:34:01 +00:00
|
|
|
recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets
|
|
|
|
updateManyAttrsByPath;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
2017-07-29 00:05:35 +00:00
|
|
|
concatMap flatten remove findSingle findFirst any all count
|
2022-12-17 20:57:17 +00:00
|
|
|
optional optionals toList range replicate partition zipListsWith zipLists
|
2023-12-07 18:51:07 +00:00
|
|
|
reverseList listDfs toposort sort sortOn naturalSort compareLists take
|
2023-06-25 11:16:06 +00:00
|
|
|
drop sublist last init crossLists unique allUnique intersectLists
|
2018-06-10 17:31:09 +00:00
|
|
|
subtractLists mutuallyExclusive groupBy groupBy';
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
2017-07-29 00:05:35 +00:00
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
2022-12-10 14:56:30 +00:00
|
|
|
concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
|
2024-04-02 17:01:05 +00:00
|
|
|
makeLibraryPath makeIncludePath makeBinPath optionalString
|
2019-02-04 08:09:38 +00:00
|
|
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
2022-12-31 00:47:28 +00:00
|
|
|
escapeShellArg escapeShellArgs
|
|
|
|
isStorePath isStringLike
|
|
|
|
isValidPosixName toShellVar toShellVars
|
2023-03-02 20:41:51 +00:00
|
|
|
escapeRegex escapeURL escapeXML replaceChars lowerChars
|
2018-05-11 15:12:15 +00:00
|
|
|
upperChars toLower toUpper addContextFrom splitString
|
2019-11-24 16:19:32 +00:00
|
|
|
removePrefix removeSuffix versionOlder versionAtLeast
|
|
|
|
getName getVersion
|
2023-09-20 23:41:57 +00:00
|
|
|
cmakeOptionType cmakeBool cmakeFeature
|
2022-11-21 00:37:31 +00:00
|
|
|
mesonOption mesonBool mesonEnable
|
2018-05-11 15:12:15 +00:00
|
|
|
nameFromURL enableFeature enableFeatureAs withFeature
|
2022-12-31 00:47:28 +00:00
|
|
|
withFeatureAs fixedWidthString fixedWidthNumber
|
2022-07-08 23:37:45 +00:00
|
|
|
toInt toIntBase10 readPathsFromFile fileContents;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.stringsWithDeps) textClosureList textClosureMap
|
2017-07-29 00:05:35 +00:00
|
|
|
noDepEntry fullDepEntry packEntry stringAfter;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.customisation) overrideDerivation makeOverridable
|
2018-05-11 15:12:15 +00:00
|
|
|
callPackageWith callPackagesWith extendDerivation hydraJob
|
2023-08-13 23:47:59 +00:00
|
|
|
makeScope makeScopeWithSplicing makeScopeWithSplicing';
|
2024-01-30 22:29:47 +00:00
|
|
|
inherit (self.derivations) lazyDerivation optionalDrvAttr;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
2018-11-18 08:26:13 +00:00
|
|
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
2023-08-13 10:27:41 +00:00
|
|
|
hiPrioSet getLicenseFromSpdxId getExe getExe';
|
2023-11-28 01:14:36 +00:00
|
|
|
inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
|
|
|
|
packagesFromDirectoryRecursive;
|
2023-04-05 14:10:09 +00:00
|
|
|
inherit (self.sources) cleanSourceFilter
|
2017-07-29 00:05:35 +00:00
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
2018-05-11 15:12:15 +00:00
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
2023-04-05 14:10:09 +00:00
|
|
|
canCleanSource pathIsGitRepo;
|
2021-12-17 14:17:49 +00:00
|
|
|
inherit (self.modules) evalModules setDefaultModuleLocation
|
2022-03-21 21:54:07 +00:00
|
|
|
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
2024-01-29 07:58:33 +00:00
|
|
|
mergeModules' mergeOptionDecls mergeDefinitions
|
2017-07-29 00:05:35 +00:00
|
|
|
pushDownProperties dischargeProperties filterOverrides
|
|
|
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
2021-08-18 12:20:41 +00:00
|
|
|
mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
|
2021-07-12 05:23:45 +00:00
|
|
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
2017-07-29 00:05:35 +00:00
|
|
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
2022-03-09 13:41:43 +00:00
|
|
|
mkRenamedOptionModule mkRenamedOptionModuleWith
|
|
|
|
mkMergedOptionModule mkChangedOptionModule
|
2022-12-30 19:43:53 +00:00
|
|
|
mkAliasOptionModule mkDerivedConfig doRename
|
|
|
|
mkAliasOptionModuleMD;
|
2024-01-29 07:58:33 +00:00
|
|
|
evalOptionValue = lib.warn "External use of `lib.evalOptionValue` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/." self.modules.evalOptionValue;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
2022-01-24 00:07:32 +00:00
|
|
|
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
|
|
|
|
getValues getFiles
|
|
|
|
optionAttrSetToDocList optionAttrSetToDocList'
|
2023-06-11 17:51:46 +00:00
|
|
|
scrubOptionValue literalExpression literalExample
|
2022-06-15 11:11:22 +00:00
|
|
|
showOption showOptionWithDefLocs showFiles
|
2022-12-30 20:04:52 +00:00
|
|
|
unknownModule mkOption mkPackageOption mkPackageOptionMD
|
2024-04-15 13:27:42 +00:00
|
|
|
mdDoc literalMD;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
2017-07-29 00:05:35 +00:00
|
|
|
isOptionType mkOptionType;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.asserts)
|
2018-08-08 17:26:52 +00:00
|
|
|
assertMsg assertOneOf;
|
2023-02-24 15:28:06 +00:00
|
|
|
inherit (self.debug) traceIf traceVal traceValFn
|
|
|
|
traceSeq traceSeqN traceValSeq
|
|
|
|
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
|
|
|
|
runTests testAllTrue;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
2017-07-29 00:05:35 +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
|
2018-07-26 10:05:40 +00:00
|
|
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
2020-05-11 22:04:41 +00:00
|
|
|
fakeHash fakeSha256 fakeSha512
|
2018-07-26 10:05:40 +00:00
|
|
|
nixType imap;
|
2020-10-20 11:47:24 +00:00
|
|
|
inherit (self.versions)
|
2019-09-24 08:47:34 +00:00
|
|
|
splitVersion;
|
2018-04-06 16:51:10 +00:00
|
|
|
});
|
2017-07-29 00:05:35 +00:00
|
|
|
in lib
|