Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,27 @@ let
let
__config = (f self);
boundAPI = builtins.mapAttrs (_: g: g (self f)) __config.api;
accAttr = attrName: acc: self (c: mapAttr (f c) attrName acc);
mergeAttrs = attrs: self (c: (f c) // attrs);
in
boundAPI
// {
inherit __config;
__functor = functor;

# Configuration updates (accumulating)
filter = filterf: self (c: mapAttr (f c) "filterf" (and filterf));
filterNot = filterf: self (c: mapAttr (f c) "filterf" (andNot filterf));
match = regex: self (c: mapAttr (f c) "filterf" (and (matchesRegex regex)));
matchNot = regex: self (c: mapAttr (f c) "filterf" (andNot (matchesRegex regex)));
map = mapf: self (c: mapAttr (f c) "mapf" (compose mapf));
addPath = path: self (c: mapAttr (f c) "paths" (p: p ++ [ path ]));
addAPI = api: self (c: mapAttr (f c) "api" (a: a // api));
filter = filterf: accAttr "filterf" (and filterf);
filterNot = filterf: accAttr "filterf" (andNot filterf);
match = regex: accAttr "filterf" (and (matchesRegex regex));
matchNot = regex: accAttr "filterf" (andNot (matchesRegex regex));
map = mapf: accAttr "mapf" (compose mapf);
addPath = path: accAttr "paths" (p: p ++ [ path ]);
addAPI = api: accAttr "api" (a: a // api);

# Configuration updates (non-accumulating)
withLib = lib: self (c: (f c) // { inherit lib; });
pipeTo = pipef: self (c: (f c) // { inherit pipef; });
leafs = self (c: (f c) // { pipef = (i: i); });
withLib = lib: mergeAttrs { inherit lib; };
pipeTo = pipef: mergeAttrs { inherit pipef; };
leafs = mergeAttrs { pipef = (i: i); };

# Applies empty (for already path-configured trees)
result = (self f) [ ];
Expand Down