lib/attrsets.nix: add unionOfDisjoint

This commit is contained in:
Adam Joseph 2022-09-05 16:11:50 -07:00
parent bf4312de3e
commit 47de66b1a4

View file

@ -622,6 +622,16 @@ rec {
dontRecurseIntoAttrs =
attrs: attrs // { recurseForDerivations = false; };
/* `unionOfDisjoint x y` is equal to `x // y // z` where the
attrnames in `z` are the intersection of the attrnames in `x` and
`y`, and all values `assert` with an error message */
unionOfDisjoint = x: y:
x // (mapAttrs
(name: val:
if hasAttr name x
then builtins.throw "attribute collision: ${name}"
else val) y);
/*** deprecated stuff ***/
zipWithNames = zipAttrsWithNames;