mergeAttrByFunc
lib.misc.mergeAttrByFunc
Docs pulled from | This Revision | 10 minutes ago
Deprecated
foldArgs, composedArgsAndFun or applyAndFun. Example: composableDerivation in all-packages.nix
Noogle detected
Implementation
The following is the current implementation of this function.
mergeAttrByFunc =
x: y:
let
mergeAttrBy2 =
{ mergeAttrBy = mergeAttrs; } // (maybeAttr "mergeAttrBy" { } x) // (maybeAttr "mergeAttrBy" { } y);
in
foldr mergeAttrs { } [
x
y
(mapAttrs
(
a: v: # merge special names using given functions
if x ? ${a} then
if y ? ${a} then
v x.${a} y.${a} # both have attr, use merge func
else
x.${a} # only x has attr
else
y.${a} # only y has attr)
)
(
removeAttrs mergeAttrBy2
# don't merge attrs which are neither in x nor y
(filter (a: !x ? ${a} && !y ? ${a}) (attrNames mergeAttrBy2))
)
)
];