Refactor `overlay.nix`

Simplify `overlay.nix` a bit by removing unnecessary filtering on
attribute values.
This commit is contained in:
Robert Helgesson 2019-03-28 23:52:37 +01:00
parent 1ab421bfa7
commit 262dabbaf2
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
1 changed files with 13 additions and 18 deletions

View File

@ -1,23 +1,18 @@
# You can use this file as a nixpkgs overlay.
# It's useful in the case where you don't want to add the whole NUR namespace
# to your configuration.
# You can use this file as a nixpkgs overlay. This is useful in the
# case where you don't want to add the whole NUR namespace to your
# configuration.
self: super:
let
filterSet =
(f: g: s: builtins.listToAttrs
(map
(n: { name = n; value = builtins.getAttr n s; })
(builtins.filter
(n: f n && g (builtins.getAttr n s))
(builtins.attrNames s)
)
)
);
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
in filterSet
(n: !(isReserved n)) # filter out non-packages
(p: true) # all packages are ok
(import ./default.nix { pkgs = super; })
isReserved = n: n == "lib" || n == "overlays" || n == "modules";
nameValuePair = n: v: { name = n; value = v; };
nurAttrs = import ./default.nix { pkgs = super; };
in
builtins.listToAttrs
(map (n: nameValuePair n nurAttrs.${n})
(builtins.filter (n: !isReserved n)
(builtins.attrNames nurAttrs)))