Created
October 12, 2019 13:03
-
-
Save offlinehacker/36d90da265886ee80e4d16c972bb925a to your computer and use it in GitHub Desktop.
Reusable utility nix functions
This file contains 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
{ | |
removeAttrByPath = attrPath: attrs: | |
let | |
recurse = residualPath: currentPath: set: | |
let | |
# if on course continue recursion else just return value | |
g = name: value: | |
if name == lib.head residualPath | |
then recurse (lib.tail residualPath) (currentPath ++ [name]) value | |
else value; | |
# if current path is same prune path | |
f = name: _: currentPath ++ [name] != attrPath; | |
in lib.mapAttrs g (lib.filterAttrs f set); | |
in recurse attrPath [] attrs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment