forked from auxolotl/core
start detangling lib
This commit is contained in:
parent
9cb4ed1ffc
commit
a4c9fde3e9
|
@ -4,169 +4,175 @@
|
||||||
* for new functions in `./tests.nix`.
|
* for new functions in `./tests.nix`.
|
||||||
*/
|
*/
|
||||||
let
|
let
|
||||||
loadStatic = (folder:
|
foundation = import ./detangled/1_foundation.nix;
|
||||||
{
|
fixedPoints = import ./detangled/2_fixed-points.nix;
|
||||||
setup = builtins.fromTOML ( builtins.readFile "${folder}/static/setup.toml" );
|
in
|
||||||
meta = builtins.fromTOML ( builtins.readFile "${folder}/static/meta.toml" );
|
let
|
||||||
}
|
static = foundation.loadStatic ../.;
|
||||||
);
|
untangledBase = {
|
||||||
static = loadStatic ../.;
|
# constants
|
||||||
untangledLib = {
|
sourceTypes = static.setup.sourceTypes;
|
||||||
# constants
|
licenses = static.setup.licenses;
|
||||||
sourceTypes = static.setup.sourceTypes;
|
maintainers = static.setup.maintainers;
|
||||||
licenses = static.setup.licenses;
|
teams = static.setup.teams;
|
||||||
maintainers = static.setup.maintainers;
|
|
||||||
teams = static.setup.teams;
|
|
||||||
|
|
||||||
builtins = builtins;# just to be overridable
|
# just to be overridable
|
||||||
loadStatic = loadStatic;
|
builtins = builtins;
|
||||||
};
|
|
||||||
|
|
||||||
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
|
# top level helpers
|
||||||
|
loadStatic = foundation.loadStatic;
|
||||||
|
foldr = foundation.foldr;
|
||||||
|
|
||||||
lib = makeExtensible (self: let
|
# namespaces
|
||||||
callLibs = file: import file { lib = self; };
|
fixedPoints = fixedPoints;
|
||||||
in untangledLib // {
|
};
|
||||||
# often used, or depending on very little
|
|
||||||
trivial = callLibs ./trivial.nix;
|
|
||||||
fixedPoints = callLibs ./fixed-points.nix;
|
|
||||||
|
|
||||||
# datatypes
|
#
|
||||||
attrsets = callLibs ./attrsets.nix;
|
# legacy lib
|
||||||
lists = callLibs ./lists.nix;
|
#
|
||||||
strings = callLibs ./strings.nix;
|
lib = fixedPoints.makeExtensible (self: let
|
||||||
stringsWithDeps = callLibs ./strings-with-deps.nix;
|
callLibs = file: import file { lib = self; };
|
||||||
|
in untangledBase // {
|
||||||
|
fixedPoints = fixedPoints;
|
||||||
|
# often used, or depending on very little
|
||||||
|
trivial = callLibs ./trivial.nix;
|
||||||
|
|
||||||
# packaging
|
# datatypes
|
||||||
customisation = callLibs ./customisation.nix;
|
attrsets = callLibs ./attrsets.nix;
|
||||||
derivations = callLibs ./derivations.nix;
|
lists = callLibs ./lists.nix;
|
||||||
meta = callLibs ./meta.nix;
|
strings = callLibs ./strings.nix;
|
||||||
versions = callLibs ./versions.nix;
|
stringsWithDeps = callLibs ./strings-with-deps.nix;
|
||||||
|
|
||||||
# module system
|
# packaging
|
||||||
modules = callLibs ./modules.nix;
|
customisation = callLibs ./customisation.nix;
|
||||||
options = callLibs ./options.nix;
|
derivations = callLibs ./derivations.nix;
|
||||||
types = callLibs ./types.nix;
|
meta = callLibs ./meta.nix;
|
||||||
|
versions = callLibs ./versions.nix;
|
||||||
|
|
||||||
# constants
|
# module system
|
||||||
systems = callLibs ./systems;
|
modules = callLibs ./modules.nix;
|
||||||
|
options = callLibs ./options.nix;
|
||||||
|
types = callLibs ./types.nix;
|
||||||
|
|
||||||
# serialization
|
# constants
|
||||||
cli = callLibs ./cli.nix;
|
systems = callLibs ./systems;
|
||||||
gvariant = callLibs ./gvariant.nix;
|
|
||||||
generators = callLibs ./generators.nix;
|
|
||||||
|
|
||||||
# misc
|
# serialization
|
||||||
asserts = callLibs ./asserts.nix;
|
cli = callLibs ./cli.nix;
|
||||||
debug = callLibs ./debug.nix;
|
gvariant = callLibs ./gvariant.nix;
|
||||||
|
generators = callLibs ./generators.nix;
|
||||||
|
|
||||||
# domain-specific
|
# misc
|
||||||
fetchers = callLibs ./fetchers.nix;
|
asserts = callLibs ./asserts.nix;
|
||||||
|
debug = callLibs ./debug.nix;
|
||||||
|
|
||||||
# Eval-time filesystem handling
|
# domain-specific
|
||||||
path = callLibs ./path;
|
fetchers = callLibs ./fetchers.nix;
|
||||||
filesystem = callLibs ./filesystem.nix;
|
|
||||||
fileset = callLibs ./fileset;
|
|
||||||
sources = callLibs ./sources.nix;
|
|
||||||
|
|
||||||
# TODO: these are not the same as system.platform, we should probably try and unify them
|
# Eval-time filesystem handling
|
||||||
# back-compat aliases
|
path = callLibs ./path;
|
||||||
platforms = self.systems.doubles;
|
filesystem = callLibs ./filesystem.nix;
|
||||||
|
fileset = callLibs ./fileset;
|
||||||
|
sources = callLibs ./sources.nix;
|
||||||
|
|
||||||
# linux kernel configuration
|
# TODO: these are not the same as system.platform, we should probably try and unify them
|
||||||
kernel = callLibs ./kernel.nix;
|
# back-compat aliases
|
||||||
|
platforms = self.systems.doubles;
|
||||||
|
|
||||||
inherit (builtins) add addErrorContext attrNames concatLists
|
# linux kernel configuration
|
||||||
deepSeq elem elemAt filter genericClosure genList getAttr
|
kernel = callLibs ./kernel.nix;
|
||||||
hasAttr head isAttrs isBool isInt isList isPath isString length
|
|
||||||
lessThan listToAttrs pathExists readFile replaceStrings seq
|
inherit (builtins) add addErrorContext attrNames concatLists
|
||||||
stringLength sub substring tail trace;
|
deepSeq elem elemAt filter genericClosure genList getAttr
|
||||||
inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
|
hasAttr head isAttrs isBool isInt isList isPath isString length
|
||||||
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
lessThan listToAttrs pathExists readFile replaceStrings seq
|
||||||
importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
|
stringLength sub substring tail trace;
|
||||||
info showWarnings nixpkgsVersion version isInOldestRelease
|
inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
|
||||||
mod compare splitByAndCompare
|
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
|
||||||
functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
|
importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
|
||||||
toHexString toBaseDigits inPureEvalMode;
|
info showWarnings nixpkgsVersion version isInOldestRelease
|
||||||
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
mod compare splitByAndCompare
|
||||||
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
functionArgs setFunctionArgs isFunction toFunction mirrorFunctionArgs
|
||||||
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
toHexString toBaseDigits inPureEvalMode;
|
||||||
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
inherit (self.fixedPoints) fix fix' converge extends composeExtensions
|
||||||
filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
|
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
||||||
mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
|
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||||
mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
|
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
||||||
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
|
||||||
recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
|
mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
|
||||||
getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
|
mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
|
||||||
recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
||||||
mapCartesianProduct updateManyAttrsByPath;
|
recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
|
||||||
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
|
||||||
ifilter0 concatMap flatten remove findSingle findFirst any all count
|
recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
|
||||||
optional optionals toList range replicate partition zipListsWith zipLists
|
mapCartesianProduct updateManyAttrsByPath;
|
||||||
reverseList listDfs toposort sort sortOn naturalSort compareLists take
|
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
||||||
drop sublist last init crossLists unique allUnique intersectLists
|
ifilter0 concatMap flatten remove findSingle findFirst any all count
|
||||||
subtractLists mutuallyExclusive groupBy groupBy';
|
optional optionals toList range replicate partition zipListsWith zipLists
|
||||||
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
reverseList listDfs toposort sort sortOn naturalSort compareLists take
|
||||||
intersperse concatStringsSep concatMapStringsSep
|
drop sublist last init crossLists unique allUnique intersectLists
|
||||||
concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
|
subtractLists mutuallyExclusive groupBy groupBy';
|
||||||
makeLibraryPath makeIncludePath makeBinPath optionalString
|
inherit (self.strings) concatStrings concatMapStrings concatImapStrings
|
||||||
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
intersperse concatStringsSep concatMapStringsSep
|
||||||
escapeShellArg escapeShellArgs
|
concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput
|
||||||
isStorePath isStringLike
|
makeLibraryPath makeIncludePath makeBinPath optionalString
|
||||||
isValidPosixName toShellVar toShellVars
|
hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
||||||
escapeRegex escapeURL escapeXML replaceChars lowerChars
|
escapeShellArg escapeShellArgs
|
||||||
upperChars toLower toUpper addContextFrom splitString
|
isStorePath isStringLike
|
||||||
removePrefix removeSuffix versionOlder versionAtLeast
|
isValidPosixName toShellVar toShellVars
|
||||||
getName getVersion
|
escapeRegex escapeURL escapeXML replaceChars lowerChars
|
||||||
cmakeOptionType cmakeBool cmakeFeature
|
upperChars toLower toUpper addContextFrom splitString
|
||||||
mesonOption mesonBool mesonEnable
|
removePrefix removeSuffix versionOlder versionAtLeast
|
||||||
nameFromURL enableFeature enableFeatureAs withFeature
|
getName getVersion
|
||||||
withFeatureAs fixedWidthString fixedWidthNumber
|
cmakeOptionType cmakeBool cmakeFeature
|
||||||
toInt toIntBase10 readPathsFromFile fileContents;
|
mesonOption mesonBool mesonEnable
|
||||||
inherit (self.stringsWithDeps) textClosureList textClosureMap
|
nameFromURL enableFeature enableFeatureAs withFeature
|
||||||
noDepEntry fullDepEntry packEntry stringAfter;
|
withFeatureAs fixedWidthString fixedWidthNumber
|
||||||
inherit (self.customisation) overrideDerivation makeOverridable
|
toInt toIntBase10 readPathsFromFile fileContents;
|
||||||
callPackageWith callPackagesWith extendDerivation hydraJob
|
inherit (self.stringsWithDeps) textClosureList textClosureMap
|
||||||
makeScope makeScopeWithSplicing makeScopeWithSplicing';
|
noDepEntry fullDepEntry packEntry stringAfter;
|
||||||
inherit (self.derivations) lazyDerivation optionalDrvAttr;
|
inherit (self.customisation) overrideDerivation makeOverridable
|
||||||
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
callPackageWith callPackagesWith extendDerivation hydraJob
|
||||||
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
makeScope makeScopeWithSplicing makeScopeWithSplicing';
|
||||||
hiPrioSet getLicenseFromSpdxId getExe getExe';
|
inherit (self.derivations) lazyDerivation optionalDrvAttr;
|
||||||
inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
|
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
||||||
packagesFromDirectoryRecursive;
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
||||||
inherit (self.sources) cleanSourceFilter
|
hiPrioSet getLicenseFromSpdxId getExe getExe';
|
||||||
cleanSource sourceByRegex sourceFilesBySuffices
|
inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile
|
||||||
commitIdFromGitRepo cleanSourceWith pathHasContext
|
packagesFromDirectoryRecursive;
|
||||||
canCleanSource pathIsGitRepo;
|
inherit (self.sources) cleanSourceFilter
|
||||||
inherit (self.modules) evalModules setDefaultModuleLocation
|
cleanSource sourceByRegex sourceFilesBySuffices
|
||||||
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
||||||
mergeModules' mergeOptionDecls mergeDefinitions
|
canCleanSource pathIsGitRepo;
|
||||||
pushDownProperties dischargeProperties filterOverrides
|
inherit (self.modules) evalModules setDefaultModuleLocation
|
||||||
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
||||||
mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
|
mergeModules' mergeOptionDecls mergeDefinitions
|
||||||
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
pushDownProperties dischargeProperties filterOverrides
|
||||||
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
||||||
mkRenamedOptionModule mkRenamedOptionModuleWith
|
mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride
|
||||||
mkMergedOptionModule mkChangedOptionModule
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
||||||
mkAliasOptionModule mkDerivedConfig doRename
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
||||||
mkAliasOptionModuleMD;
|
mkRenamedOptionModule mkRenamedOptionModuleWith
|
||||||
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
mkMergedOptionModule mkChangedOptionModule
|
||||||
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
|
mkAliasOptionModule mkDerivedConfig doRename
|
||||||
getValues getFiles
|
mkAliasOptionModuleMD;
|
||||||
optionAttrSetToDocList optionAttrSetToDocList'
|
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||||
scrubOptionValue literalExpression literalExample
|
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
|
||||||
showOption showOptionWithDefLocs showFiles
|
getValues getFiles
|
||||||
unknownModule mkOption mkPackageOption mkPackageOptionMD
|
optionAttrSetToDocList optionAttrSetToDocList'
|
||||||
mdDoc literalMD;
|
scrubOptionValue literalExpression literalExample
|
||||||
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
showOption showOptionWithDefLocs showFiles
|
||||||
isOptionType mkOptionType;
|
unknownModule mkOption mkPackageOption mkPackageOptionMD
|
||||||
inherit (self.asserts)
|
mdDoc literalMD;
|
||||||
assertMsg assertOneOf;
|
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
||||||
inherit (self.debug) traceIf traceVal traceValFn
|
isOptionType mkOptionType;
|
||||||
traceSeq traceSeqN traceValSeq
|
inherit (self.asserts)
|
||||||
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
|
assertMsg assertOneOf;
|
||||||
runTests testAllTrue;
|
inherit (self.debug) traceIf traceVal traceValFn
|
||||||
inherit (self.versions)
|
traceSeq traceSeqN traceValSeq
|
||||||
splitVersion;
|
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
|
||||||
});
|
runTests testAllTrue;
|
||||||
in lib
|
inherit (self.versions)
|
||||||
|
splitVersion;
|
||||||
|
});
|
||||||
|
in lib
|
||||||
|
|
22
nodes/1_lib/source/detangled/1_foundation.nix
Normal file
22
nodes/1_lib/source/detangled/1_foundation.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# foundation contains functions that only depend on builtins
|
||||||
|
#
|
||||||
|
{
|
||||||
|
loadStatic = (folder:
|
||||||
|
{
|
||||||
|
setup = builtins.fromTOML ( builtins.readFile "${folder}/static/setup.toml" );
|
||||||
|
meta = builtins.fromTOML ( builtins.readFile "${folder}/static/meta.toml" );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
foldr = (
|
||||||
|
op: nul: list:
|
||||||
|
let
|
||||||
|
len = builtins.length list;
|
||||||
|
fold' = n:
|
||||||
|
if n == len
|
||||||
|
then nul
|
||||||
|
else op (builtins.elemAt list n) (fold' (n + 1));
|
||||||
|
in
|
||||||
|
fold' 0
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
{ foldr }:
|
let # internal lib dependencies
|
||||||
|
foundation = import ./1_foundation.nix;
|
||||||
|
in
|
||||||
let
|
let
|
||||||
/*
|
/*
|
||||||
`fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
|
`fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
|
||||||
|
@ -274,7 +276,7 @@
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
composeManyExtensions =
|
composeManyExtensions =
|
||||||
foldr (x: y: composeExtensions x y) (final: prev: {});
|
foundation.foldr (x: y: composeExtensions x y) (final: prev: {});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Same as `makeExtensible` but the name of the extending attribute is
|
Same as `makeExtensible` but the name of the extending attribute is
|
Loading…
Reference in a new issue