The pipe operator '<|' was added in Nix 2.24 as experimental. In typical nix community fashion, an eternity has passed, it's still experimental, and they're still arguing about it. Thus, in order not to burden any users of this flake, they have been removed. To get this done quickly a utility function has been added called 'compose'. It is 'lib.trivial.pipe' written in reverse. This eliminates any bugs and performance regressions from unnecessary thunk evaluation.
31 lines
820 B
Nix
31 lines
820 B
Nix
lib: {
|
|
hylonix = {
|
|
recursiveMerge =
|
|
let
|
|
f =
|
|
x: y:
|
|
if y == null then
|
|
x
|
|
else if builtins.typeOf x != builtins.typeOf y then
|
|
y
|
|
else if builtins.typeOf x == "set" then
|
|
builtins.listToAttrs (
|
|
builtins.map (name: {
|
|
inherit name;
|
|
value = f (x.${name} or null) (y.${name} or null);
|
|
}) (builtins.attrNames y ++ builtins.attrNames x)
|
|
)
|
|
else if builtins.typeOf x == "list" then
|
|
x ++ y
|
|
else
|
|
y;
|
|
in
|
|
f;
|
|
|
|
recursiveMergeAll = builtins.foldl' lib.hylonix.recursiveMerge null;
|
|
|
|
compose = lib.trivial.flip (lib.foldr lib.trivial.id);
|
|
};
|
|
|
|
inherit (lib.hylonix) compose recursiveMerge recursiveMergeAll;
|
|
}
|