core/lib/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

501 lines
11 KiB
Nix
Raw Normal View History

2024-05-01 22:14:04 +00:00
/*
Library of low-level helper functions for nix expressions.
2024-06-30 08:12:46 +00:00
2024-05-01 22:14:04 +00:00
Please implement (mostly) exhaustive unit tests
for new functions in `./tests.nix`.
*/
let
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
lib = makeExtensible (
self:
let
callLibs = file: import file { lib = self; };
in
{
# 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;
derivations = callLibs ./derivations.nix;
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;
sourceTypes = callLibs ./source-types.nix;
systems = callLibs ./systems;
# serialization
cli = callLibs ./cli.nix;
gvariant = callLibs ./gvariant.nix;
generators = callLibs ./generators.nix;
# misc
asserts = callLibs ./asserts.nix;
debug = callLibs ./debug.nix;
misc = callLibs ./deprecated/misc.nix;
# domain-specific
fetchers = callLibs ./fetchers.nix;
# Eval-time filesystem handling
path = callLibs ./path;
filesystem = callLibs ./filesystem.nix;
fileset = callLibs ./fileset;
sources = callLibs ./sources.nix;
# back-compat aliases
platforms = self.systems.doubles;
# 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
isPath
isString
length
lessThan
listToAttrs
pathExists
readFile
replaceStrings
seq
stringLength
sub
substring
tail
trace
;
inherit (self.trivial)
id
const
pipe
concat
or
and
xor
bitAnd
bitOr
bitXor
bitNot
boolToString
mergeAttrs
flip
mapNullable
inNixShell
isFloat
min
max
importJSON
importTOML
warn
warnIf
warnIfNot
throwIf
throwIfNot
checkListOfEnum
info
showWarnings
nixpkgsVersion
version
isInOldestRelease
mod
compare
splitByAndCompare
functionArgs
setFunctionArgs
isFunction
toFunction
mirrorFunctionArgs
toHexString
toBaseDigits
inPureEvalMode
;
inherit (self.fixedPoints)
fix
fix'
converge
extends
composeExtensions
composeManyExtensions
makeExtensible
makeExtensibleWithCustomName
;
inherit (self.attrsets)
attrByPath
hasAttrByPath
setAttrByPath
getAttrFromPath
attrVals
attrValues
getAttrs
catAttrs
filterAttrs
filterAttrsRecursive
foldlAttrs
foldAttrs
collect
nameValuePair
mapAttrs
mapAttrs'
mapAttrsToList
attrsToList
concatMapAttrs
mapAttrsRecursive
mapAttrsRecursiveCond
genAttrs
isDerivation
toDerivation
optionalAttrs
zipAttrsWithNames
zipAttrsWith
zipAttrs
recursiveUpdateUntil
recursiveUpdate
matchAttrs
mergeAttrsList
overrideExisting
showAttrPath
getOutput
getBin
getLib
getDev
getMan
chooseDevOutputs
zipWithNames
zip
recurseIntoAttrs
dontRecurseIntoAttrs
cartesianProduct
cartesianProductOfSets
mapCartesianProduct
updateManyAttrsByPath
;
inherit (self.lists)
singleton
forEach
foldr
fold
foldl
foldl'
imap0
imap1
ifilter0
concatMap
flatten
2024-06-30 08:12:46 +00:00
remove
2024-05-01 22:14:04 +00:00
findSingle
findFirst
2024-06-30 08:12:46 +00:00
any
all
2024-05-01 22:14:04 +00:00
count
optional
optionals
toList
range
replicate
partition
zipListsWith
2024-06-30 08:12:46 +00:00
zipLists
2024-05-01 22:14:04 +00:00
reverseList
2024-06-30 08:12:46 +00:00
listDfs
2024-05-01 22:14:04 +00:00
toposort
2024-06-30 08:12:46 +00:00
sort
2024-05-01 22:14:04 +00:00
sortOn
naturalSort
compareLists
take
2024-06-30 08:12:46 +00:00
drop
sublist
2024-05-01 22:14:04 +00:00
last
init
crossLists
unique
allUnique
intersectLists
subtractLists
mutuallyExclusive
2024-06-30 08:12:46 +00:00
groupBy
groupBy'
;
2024-05-01 22:14:04 +00:00
inherit (self.strings)
concatStrings
concatMapStrings
concatImapStrings
intersperse
concatStringsSep
concatMapStringsSep
concatImapStringsSep
concatLines
makeSearchPath
makeSearchPathOutput
makeLibraryPath
makeIncludePath
makeBinPath
optionalString
2024-06-30 08:12:46 +00:00
hasInfix
2024-05-01 22:14:04 +00:00
hasPrefix
hasSuffix
stringToCharacters
stringAsChars
escape
escapeShellArg
escapeShellArgs
isStorePath
isStringLike
isValidPosixName
2024-06-30 08:12:46 +00:00
toShellVar
toShellVars
2024-05-01 22:14:04 +00:00
escapeRegex
escapeURL
escapeXML
replaceChars
lowerChars
2024-06-30 08:12:46 +00:00
upperChars
toLower
toUpper
2024-05-01 22:14:04 +00:00
addContextFrom
splitString
removePrefix
removeSuffix
versionOlder
versionAtLeast
getName
getVersion
cmakeOptionType
cmakeBool
cmakeFeature
mesonOption
mesonBool
mesonEnable
nameFromURL
enableFeature
enableFeatureAs
withFeature
withFeatureAs
fixedWidthString
fixedWidthNumber
2024-06-30 08:12:46 +00:00
toInt
2024-05-01 22:14:04 +00:00
toIntBase10
readPathsFromFile
fileContents
;
inherit (self.stringsWithDeps)
textClosureList
textClosureMap
noDepEntry
fullDepEntry
2024-06-30 08:12:46 +00:00
packEntry
2024-05-01 22:14:04 +00:00
stringAfter
;
inherit (self.customisation)
overrideDerivation
makeOverridable
callPackageWith
callPackagesWith
extendDerivation
2024-06-30 08:12:46 +00:00
hydraJob
2024-05-01 22:14:04 +00:00
makeScope
makeScopeWithSplicing
makeScopeWithSplicing'
;
inherit (self.derivations) lazyDerivation optionalDrvAttr;
inherit (self.meta)
addMetaAttrs
dontDistribute
2024-06-30 08:12:46 +00:00
setName
2024-05-01 22:14:04 +00:00
updateName
appendToName
mapDerivationAttrset
2024-06-30 08:12:46 +00:00
setPrio
lowPrio
2024-05-01 22:14:04 +00:00
lowPrioSet
2024-06-30 08:12:46 +00:00
hiPrio
2024-05-01 22:14:04 +00:00
hiPrioSet
getLicenseFromSpdxId
2024-06-30 08:12:46 +00:00
getExe
getExe'
;
2024-05-01 22:14:04 +00:00
inherit (self.filesystem)
2024-06-30 08:12:46 +00:00
pathType
2024-05-01 22:14:04 +00:00
pathIsDirectory
pathIsRegularFile
packagesFromDirectoryRecursive
2024-06-30 08:12:46 +00:00
;
2024-05-01 22:14:04 +00:00
inherit (self.sources)
cleanSourceFilter
cleanSource
sourceByRegex
sourceFilesBySuffices
commitIdFromGitRepo
cleanSourceWith
2024-06-30 08:12:46 +00:00
pathHasContext
2024-05-01 22:14:04 +00:00
canCleanSource
pathIsGitRepo
2024-06-30 08:12:46 +00:00
;
2024-05-01 22:14:04 +00:00
inherit (self.modules)
evalModules
setDefaultModuleLocation
unifyModuleSyntax
applyModuleArgsIfFunction
mergeModules
mergeModules'
mergeOptionDecls
mergeDefinitions
pushDownProperties
dischargeProperties
filterOverrides
sortProperties
fixupOptionType
mkIf
mkAssert
mkMerge
mkOverride
mkOptionDefault
mkDefault
mkImageMediaOverride
mkForce
mkVMOverride
mkFixStrictness
mkOrder
mkBefore
2024-06-30 08:12:46 +00:00
mkAfter
2024-05-01 22:14:04 +00:00
mkAliasDefinitions
mkAliasAndWrapDefinitions
fixMergeModules
mkRemovedOptionModule
mkRenamedOptionModule
mkRenamedOptionModuleWith
mkMergedOptionModule
mkChangedOptionModule
mkAliasOptionModule
mkDerivedConfig
doRename
mkAliasOptionModuleMD
;
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;
inherit (self.options)
isOption
mkEnableOption
mkSinkUndeclaredOptions
mergeDefaultOption
mergeOneOption
mergeEqualOption
mergeUniqueOption
getValues
getFiles
optionAttrSetToDocList
optionAttrSetToDocList'
scrubOptionValue
literalExpression
literalExample
showOption
showOptionWithDefLocs
showFiles
unknownModule
mkOption
mkPackageOption
mkPackageOptionMD
mdDoc
literalMD
;
inherit (self.types)
isType
setType
defaultTypeMerge
defaultFunctor
isOptionType
mkOptionType
;
inherit (self.asserts) assertMsg assertOneOf;
inherit (self.debug)
traceIf
traceVal
traceValFn
traceSeq
traceSeqN
traceValSeq
traceValSeqFn
traceValSeqN
traceValSeqNFn
traceFnSeqN
runTests
testAllTrue
;
inherit (self.misc)
maybeEnv
defaultMergeArg
defaultMerge
foldArgs
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
fakeHash
fakeSha256
fakeSha512
nixType
imap
;
inherit (self.versions) splitVersion;
}
);
in
lib