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

View file

@ -1,23 +1,18 @@
# You can use this file as a nixpkgs overlay. # You can use this file as a nixpkgs overlay. This is useful in the
# It's useful in the case where you don't want to add the whole NUR namespace # case where you don't want to add the whole NUR namespace to your
# to your configuration. # configuration.
self: super: self: super:
let 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)))