tests for PoC!
This commit is contained in:
parent
15ed56d8ad
commit
447ae19b3c
13 changed files with 450 additions and 19 deletions
24
modules/dynamicism/lib.nix
Normal file
24
modules/dynamicism/lib.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
lib ? import <nixpkgs/lib>,
|
||||
}: let
|
||||
t = lib.types;
|
||||
in lib.fix (self: {
|
||||
/** Perform module-system type checking and resolving on a single option value. */
|
||||
typeCheck = loc: option: value:
|
||||
assert lib.isOptionType option;
|
||||
assert lib.isList loc;
|
||||
assert lib.all lib.isString loc;
|
||||
let
|
||||
merged = lib.modules.mergeDefinitions loc option [ {
|
||||
inherit value;
|
||||
file = "«inline»";
|
||||
} ];
|
||||
in merged.mergedValue;
|
||||
|
||||
/** Either a list of strings, or a dotted string that will be split. */
|
||||
convenientAttrPath = t.coercedTo t.str (lib.splitString ".") (t.listOf t.str);
|
||||
|
||||
concatFoldl = f: list: lib.foldl' (acc: value: acc ++ (f value)) [ ] list;
|
||||
recUpdateFoldl = f: list: lib.foldl' (acc: value: lib.recursiveUpdate acc (f value)) { } list;
|
||||
recUpdateFoldlAttrs = f: attrs: lib.foldlAttrs (acc: name: value: lib.recursiveUpdate acc (f name value)) { } attrs;
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue