2020-04-24 23:36:52 +00:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
2023-01-11 07:51:40 +00:00
|
|
|
* for new functions in `./tests.nix`.
|
2020-04-24 23:36:52 +00:00
|
|
|
*/
|
|
|
|
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;
|
2022-09-30 11:47:45 +00:00
|
|
|
derivations = callLibs ./derivations.nix;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = import ../maintainers/maintainer-list.nix;
|
|
|
|
teams = callLibs ../maintainers/team-list.nix;
|
|
|
|
meta = callLibs ./meta.nix;
|
|
|
|
versions = callLibs ./versions.nix;
|
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
2022-06-16 17:23:12 +00:00
|
|
|
sourceTypes = callLibs ./source-types.nix;
|
2020-04-24 23:36:52 +00:00
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
|
|
|
# serialization
|
|
|
|
cli = callLibs ./cli.nix;
|
2023-10-09 19:29:22 +00:00
|
|
|
gvariant = callLibs ./gvariant.nix;
|
2020-04-24 23:36:52 +00:00
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
|
|
|
|
# misc
|
|
|
|
asserts = callLibs ./asserts.nix;
|
|
|
|
debug = callLibs ./debug.nix;
|
2024-05-15 15:35:15 +00:00
|
|
|
misc = callLibs ./deprecated/misc.nix;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# domain-specific
|
|
|
|
fetchers = callLibs ./fetchers.nix;
|
|
|
|
|
|
|
|
# Eval-time filesystem handling
|
2023-01-11 07:51:40 +00:00
|
|
|
path = callLibs ./path;
|
2020-04-24 23:36:52 +00:00
|
|
|
filesystem = callLibs ./filesystem.nix;
|
2023-10-09 19:29:22 +00:00
|
|
|
fileset = callLibs ./fileset;
|
2023-01-11 07:51:40 +00:00
|
|
|
sources = callLibs ./sources.nix;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
# TODO: For consistency, all builtins should also be available from a sub-library;
|
|
|
|
# these are the only ones that are currently not
|
|
|
|
inherit (builtins) addErrorContext isPath trace;
|
2024-04-21 15:54:59 +00:00
|
|
|
inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
|
2020-10-27 00:29:36 +00:00
|
|
|
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
2022-03-30 09:31:56 +00:00
|
|
|
importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
|
|
|
|
info showWarnings nixpkgsVersion version isInOldestRelease
|
2024-06-24 18:47:55 +00:00
|
|
|
mod compare splitByAndCompare seq deepSeq lessThan add sub
|
2023-11-16 04:20:00 +00:00
|
|
|
functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
|
2024-06-24 18:47:55 +00:00
|
|
|
toHexString toBaseDigits inPureEvalMode isBool isInt pathExists
|
|
|
|
genericClosure readFile;
|
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
|
2024-06-24 18:47:55 +00:00
|
|
|
getAttrFromPath attrVals attrNames attrValues getAttrs catAttrs filterAttrs
|
2023-03-15 16:39:30 +00:00
|
|
|
filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
|
2023-10-19 13:55:26 +00:00
|
|
|
mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
|
|
|
|
mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
|
2020-04-24 23:36:52 +00:00
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
2024-02-29 20:09:43 +00:00
|
|
|
recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
|
|
|
|
getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
|
2024-04-21 15:54:59 +00:00
|
|
|
recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
|
2024-06-24 18:47:55 +00:00
|
|
|
mapCartesianProduct updateManyAttrsByPath listToAttrs hasAttr getAttr isAttrs intersectAttrs removeAttrs;
|
|
|
|
inherit (self.lists) singleton forEach map foldr fold foldl foldl' imap0 imap1
|
|
|
|
filter ifilter0 concatMap flatten remove findSingle findFirst any all count
|
2023-02-09 11:40:11 +00:00
|
|
|
optional optionals toList range replicate partition zipListsWith zipLists
|
2024-01-02 11:29:13 +00:00
|
|
|
reverseList listDfs toposort sort sortOn naturalSort compareLists take
|
2023-11-16 04:20:00 +00:00
|
|
|
drop sublist last init crossLists unique allUnique intersectLists
|
2024-06-24 18:47:55 +00:00
|
|
|
subtractLists mutuallyExclusive groupBy groupBy' concatLists genList
|
|
|
|
length head tail elem elemAt isList;
|
2020-10-27 00:29:36 +00:00
|
|
|
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
2024-06-24 18:47:55 +00:00
|
|
|
stringLength substring isString replaceStrings
|
2020-04-24 23:36:52 +00:00
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
2023-02-02 18:25:31 +00:00
|
|
|
concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
|
2024-04-21 15:54:59 +00:00
|
|
|
makeLibraryPath makeIncludePath makeBinPath optionalString
|
2020-04-24 23:36:52 +00:00
|
|
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
2023-01-11 07:51:40 +00:00
|
|
|
escapeShellArg escapeShellArgs
|
|
|
|
isStorePath isStringLike
|
|
|
|
isValidPosixName toShellVar toShellVars
|
2023-03-04 12:14:45 +00:00
|
|
|
escapeRegex escapeURL escapeXML replaceChars lowerChars
|
2020-04-24 23:36:52 +00:00
|
|
|
upperChars toLower toUpper addContextFrom splitString
|
|
|
|
removePrefix removeSuffix versionOlder versionAtLeast
|
2024-06-24 18:47:55 +00:00
|
|
|
getName getVersion match split
|
2023-10-09 19:29:22 +00:00
|
|
|
cmakeOptionType cmakeBool cmakeFeature
|
2022-12-17 10:02:37 +00:00
|
|
|
mesonOption mesonBool mesonEnable
|
2020-04-24 23:36:52 +00:00
|
|
|
nameFromURL enableFeature enableFeatureAs withFeature
|
2023-01-11 07:51:40 +00:00
|
|
|
withFeatureAs fixedWidthString fixedWidthNumber
|
2022-10-30 15:09:59 +00:00
|
|
|
toInt toIntBase10 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
|
2023-08-22 20:05:09 +00:00
|
|
|
makeScope makeScopeWithSplicing makeScopeWithSplicing';
|
2024-02-07 01:22:34 +00:00
|
|
|
inherit (self.derivations) lazyDerivation optionalDrvAttr;
|
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
|
2023-08-22 20:05:09 +00:00
|
|
|
hiPrioSet getLicenseFromSpdxId getExe getExe';
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
|
|
|
|
packagesFromDirectoryRecursive;
|
2023-05-24 13:37:59 +00:00
|
|
|
inherit (self.sources) cleanSourceFilter
|
2020-04-24 23:36:52 +00:00
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
2023-05-24 13:37:59 +00:00
|
|
|
canCleanSource pathIsGitRepo;
|
2022-02-10 20:34:41 +00:00
|
|
|
inherit (self.modules) evalModules setDefaultModuleLocation
|
2022-03-30 09:31:56 +00:00
|
|
|
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
2024-04-21 15:54:59 +00:00
|
|
|
mergeModules' mergeOptionDecls mergeDefinitions
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2022-03-30 09:31:56 +00:00
|
|
|
mkRenamedOptionModule mkRenamedOptionModuleWith
|
|
|
|
mkMergedOptionModule mkChangedOptionModule
|
2023-01-11 07:51:40 +00:00
|
|
|
mkAliasOptionModule mkDerivedConfig doRename
|
|
|
|
mkAliasOptionModuleMD;
|
2024-04-21 15:54:59 +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-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'
|
2023-07-15 17:15:38 +00:00
|
|
|
scrubOptionValue literalExpression literalExample
|
2022-06-26 10:26:21 +00:00
|
|
|
showOption showOptionWithDefLocs showFiles
|
2023-01-11 07:51:40 +00:00
|
|
|
unknownModule mkOption mkPackageOption mkPackageOptionMD
|
2022-06-26 10:26:21 +00:00
|
|
|
mdDoc literalMD;
|
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;
|
2023-03-08 16:32:21 +00:00
|
|
|
inherit (self.debug) traceIf traceVal traceValFn
|
|
|
|
traceSeq traceSeqN traceValSeq
|
|
|
|
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
|
|
|
|
runTests testAllTrue;
|
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
|