Skip to content

Instantly share code, notes, and snippets.

@terlar
Created May 24, 2024 18:40
Show Gist options
  • Save terlar/a429bc3b21d872c3eddcae86ffd3a979 to your computer and use it in GitHub Desktop.
Save terlar/a429bc3b21d872c3eddcae86ffd3a979 to your computer and use it in GitHub Desktop.
{ lib }:
{
filterDivergedAttrsRecursive =
lhs: rhs:
let
pred = path: v: (!lib.hasAttrByPath path rhs || (lib.getAttrFromPath path rhs) != v);
recurse =
path: set:
lib.listToAttrs (
lib.concatMap (
name:
let
v = set.${name};
p = path ++ [ name ];
in
if pred p v then [ (lib.nameValuePair name (if lib.isAttrs v then recurse p v else v)) ] else [ ]
) (lib.attrNames set)
);
in
recurse [ ] lhs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment