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