diff options
author | Brian Picciano <me@mediocregopher.com> | 2024-01-06 15:57:47 +0100 |
---|---|---|
committer | Brian Picciano <me@mediocregopher.com> | 2024-01-06 15:57:47 +0100 |
commit | 83b17c5ceecc9b8c9a285feae8f2b516740ab915 (patch) | |
tree | 6f92b2d8799fe5c512f29eb8049631b157e562c1 | |
parent | f814ddd972c76e96b2c82cfed6bef2f07cdfc48e (diff) |
Make config merging smarter
-rw-r--r-- | default.nix | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/default.nix b/default.nix index ca1aa5f..d97ecb4 100644 --- a/default.nix +++ b/default.nix @@ -8,7 +8,20 @@ }: let - config = (import ./config/default.nix) // hostConfig ; + recursiveMerge = with pkgs.lib; attrList: + let f = attrPath: + zipAttrsWith (n: values: + if tail values == [] + then head values + else if all isList values + then unique (concatLists values) + else if all isAttrs values + then f (attrPath ++ [n]) values + else last values + ); + in f [] attrList; + + config = recursiveMerge [ (import ./config/default.nix) hostConfig ]; in rec { |