Created
May 24, 2024 18:40
-
-
Save terlar/a429bc3b21d872c3eddcae86ffd3a979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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