2017-03-30 14:03:40 -06:00
|
|
|
/* Library of low-level helper functions for nix expressions.
|
|
|
|
*
|
|
|
|
* Please implement (mostly) exhaustive unit tests
|
|
|
|
* for new functions in `./tests.nix'.
|
|
|
|
*/
|
2016-09-14 17:21:42 -06:00
|
|
|
let
|
2006-09-25 04:07:59 -06:00
|
|
|
|
2018-04-06 10:51:10 -06:00
|
|
|
inherit (import ./fixed-points.nix {}) makeExtensible;
|
2017-07-28 18:05:35 -06:00
|
|
|
|
2018-04-06 10:51:10 -06:00
|
|
|
lib = makeExtensible (self: let
|
|
|
|
callLibs = file: import file { lib = self; };
|
|
|
|
in with self; {
|
2017-07-28 18:05:35 -06: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;
|
2018-03-03 20:09:35 -07:00
|
|
|
maintainers = import ../maintainers/maintainer-list.nix;
|
2017-07-28 18:05:35 -06:00
|
|
|
meta = callLibs ./meta.nix;
|
|
|
|
sources = callLibs ./sources.nix;
|
2018-03-02 21:26:32 -07:00
|
|
|
versions = callLibs ./versions.nix;
|
2017-07-28 18:05:35 -06:00
|
|
|
|
|
|
|
# module system
|
|
|
|
modules = callLibs ./modules.nix;
|
|
|
|
options = callLibs ./options.nix;
|
|
|
|
types = callLibs ./types.nix;
|
|
|
|
|
|
|
|
# constants
|
|
|
|
licenses = callLibs ./licenses.nix;
|
|
|
|
systems = callLibs ./systems;
|
|
|
|
|
|
|
|
# misc
|
2018-08-08 11:26:52 -06:00
|
|
|
asserts = callLibs ./asserts.nix;
|
2017-07-28 18:05:35 -06:00
|
|
|
debug = callLibs ./debug.nix;
|
|
|
|
generators = callLibs ./generators.nix;
|
|
|
|
misc = callLibs ./deprecated.nix;
|
2018-08-08 11:26:52 -06:00
|
|
|
|
2017-07-28 18:05:35 -06:00
|
|
|
# domain-specific
|
|
|
|
fetchers = callLibs ./fetchers.nix;
|
|
|
|
|
|
|
|
# Eval-time filesystem handling
|
|
|
|
filesystem = callLibs ./filesystem.nix;
|
2017-02-08 19:27:22 -07:00
|
|
|
|
|
|
|
# back-compat aliases
|
2019-04-27 18:37:42 -06:00
|
|
|
platforms = systems.doubles;
|
2017-07-28 18:05:35 -06:00
|
|
|
|
2018-05-11 09:12:15 -06:00
|
|
|
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
|
|
|
|
stringLength sub substring tail;
|
2018-06-10 13:25:48 -06:00
|
|
|
inherit (trivial) id const concat or and bitAnd bitOr bitXor bitNot
|
|
|
|
boolToString mergeAttrs flip mapNullable inNixShell min max
|
2019-02-23 11:06:51 -07:00
|
|
|
importJSON warn info showWarnings nixpkgsVersion version mod compare
|
2018-08-08 11:26:52 -06:00
|
|
|
splitByAndCompare functionArgs setFunctionArgs isFunction;
|
2018-12-11 14:18:22 -07:00
|
|
|
inherit (fixedPoints) fix fix' converge extends composeExtensions
|
2017-09-29 07:10:48 -06:00
|
|
|
makeExtensible makeExtensibleWithCustomName;
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
2018-12-11 14:18:22 -07:00
|
|
|
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
2017-07-28 18:05:35 -06:00
|
|
|
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
|
|
|
mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
|
|
|
|
genAttrs isDerivation toDerivation optionalAttrs
|
|
|
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
|
|
|
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
|
|
|
getLib getDev chooseDevOutputs zipWithNames zip;
|
|
|
|
inherit (lists) singleton foldr fold foldl foldl' imap0 imap1
|
|
|
|
concatMap flatten remove findSingle findFirst any all count
|
|
|
|
optional optionals toList range partition zipListsWith zipLists
|
2018-05-11 09:12:15 -06:00
|
|
|
reverseList listDfs toposort sort naturalSort compareLists take
|
|
|
|
drop sublist last init crossLists unique intersectLists
|
2018-06-10 11:31:09 -06:00
|
|
|
subtractLists mutuallyExclusive groupBy groupBy';
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
|
|
|
intersperse concatStringsSep concatMapStringsSep
|
|
|
|
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
2018-12-14 20:50:31 -07:00
|
|
|
makeLibraryPath makeBinPath optionalString
|
2019-02-04 01:09:38 -07:00
|
|
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
2018-05-11 09:12:15 -06:00
|
|
|
escapeShellArg escapeShellArgs replaceChars lowerChars
|
|
|
|
upperChars toLower toUpper addContextFrom splitString
|
|
|
|
removePrefix removeSuffix versionOlder versionAtLeast getVersion
|
|
|
|
nameFromURL enableFeature enableFeatureAs withFeature
|
|
|
|
withFeatureAs fixedWidthString fixedWidthNumber isStorePath
|
2017-07-28 18:05:35 -06:00
|
|
|
toInt readPathsFromFile fileContents;
|
|
|
|
inherit (stringsWithDeps) textClosureList textClosureMap
|
|
|
|
noDepEntry fullDepEntry packEntry stringAfter;
|
|
|
|
inherit (customisation) overrideDerivation makeOverridable
|
2018-05-11 09:12:15 -06:00
|
|
|
callPackageWith callPackagesWith extendDerivation hydraJob
|
|
|
|
makeScope;
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (meta) addMetaAttrs dontDistribute setName updateName
|
2018-11-18 01:26:13 -07:00
|
|
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
2017-07-28 18:05:35 -06:00
|
|
|
hiPrioSet;
|
|
|
|
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
|
|
|
cleanSource sourceByRegex sourceFilesBySuffices
|
2018-05-11 09:12:15 -06:00
|
|
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
|
|
|
canCleanSource;
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (modules) evalModules closeModules unifyModuleSyntax
|
|
|
|
applyIfFunction unpackSubmodule packSubmodule mergeModules
|
|
|
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
|
|
|
pushDownProperties dischargeProperties filterOverrides
|
|
|
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
|
|
|
mkOptionDefault mkDefault mkForce mkVMOverride mkStrict
|
|
|
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
|
|
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
|
|
|
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
2019-01-23 20:58:33 -07:00
|
|
|
mkAliasOptionModule doRename filterModules;
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
|
|
|
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
|
|
|
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
|
|
|
scrubOptionValue literalExample showOption showFiles
|
|
|
|
unknownModule mkOption;
|
|
|
|
inherit (types) isType setType defaultTypeMerge defaultFunctor
|
|
|
|
isOptionType mkOptionType;
|
2018-08-08 11:26:52 -06:00
|
|
|
inherit (asserts)
|
|
|
|
assertMsg assertOneOf;
|
2018-04-02 09:21:35 -06:00
|
|
|
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
2017-07-28 18:05:35 -06:00
|
|
|
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
2018-04-02 09:21:35 -06:00
|
|
|
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
|
|
|
|
traceShowValMarked showVal traceCall traceCall2 traceCall3
|
2018-05-11 09:12:15 -06:00
|
|
|
traceValIfNot runTests testAllTrue traceCallXml attrNamesToStr;
|
2017-07-28 18:05:35 -06:00
|
|
|
inherit (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
|
2018-07-26 04:05:40 -06:00
|
|
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
lib: add shortcuts for fake hashes (fakeSha256, fakeSha512)
Fake hashes can be used as placeholders for all the places, where
Nix expression requires a hash, but we don't yet have one.
This should be more convenient than following:
- echo|sha256sum, copy into clipboard, go to editor, paste into previously
edited place
- search nixpkgs for a random package, copy it's hash to cliboard, go to
editor, paste into previously edited place
Nix can add support for these fake hashes. In that case printed error should contain
only 1 hash, so no more problem "which of two hashes from error should I use?"
Idea by irc:Synthetica
2019-01-10 06:08:50 -07:00
|
|
|
fakeSha256 fakeSha512
|
2018-07-26 04:05:40 -06:00
|
|
|
nixType imap;
|
2018-04-06 10:51:10 -06:00
|
|
|
});
|
2017-07-28 18:05:35 -06:00
|
|
|
in lib
|