Refactor overlay.nix
Simplify `overlay.nix` a bit by removing unnecessary filtering on attribute values.
This commit is contained in:
parent
1ab421bfa7
commit
262dabbaf2
1 changed files with 13 additions and 18 deletions
31
overlay.nix
31
overlay.nix
|
@ -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)))
|
||||
|
|
Loading…
Reference in a new issue