Clean up the filtering

This commit is contained in:
Francesco Gazzetta 2019-03-23 19:03:43 +01:00
parent ea430a68d0
commit 1110dde8dc
2 changed files with 26 additions and 25 deletions

View File

@ -4,24 +4,23 @@
# be added to the cache. # be added to the cache.
{ pkgs ? import <nixpkgs> {} }: { pkgs ? import <nixpkgs> {} }:
let filterSet = let
(f: g: s: builtins.listToAttrs filterSet =
(map (f: g: s: builtins.listToAttrs
(n: { name = n; value = builtins.getAttr n s; }) (map
(builtins.filter (n: { name = n; value = builtins.getAttr n s; })
(n: f n && g (builtins.getAttr n s)) (builtins.filter
(builtins.attrNames s) (n: f n && g (builtins.getAttr n s))
) (builtins.attrNames s)
) )
); )
);
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
isBroken = p: ({ meta.broken = false; } // p).meta.broken;
in filterSet in filterSet
(n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages (n: !(isReserved n)) # filter out non-packages
(p: (builtins.isAttrs p) (p: (builtins.isAttrs p)
&& !( && !(isBroken p)
(builtins.hasAttr "meta" p)
&& (builtins.hasAttr "broken" p.meta)
&& (p.meta.broken)
)
) )
(import ./default.nix { inherit pkgs; }) (import ./default.nix { inherit pkgs; })

View File

@ -4,18 +4,20 @@
self: super: self: super:
let filterSet = let
(f: g: s: builtins.listToAttrs filterSet =
(map (f: g: s: builtins.listToAttrs
(n: { name = n; value = builtins.getAttr n s; }) (map
(builtins.filter (n: { name = n; value = builtins.getAttr n s; })
(n: f n && g (builtins.getAttr n s)) (builtins.filter
(builtins.attrNames s) (n: f n && g (builtins.getAttr n s))
) (builtins.attrNames s)
) )
); )
);
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
in filterSet in filterSet
(n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages (n: !(isReserved n)) # filter out non-packages
(p: true) # all packages are ok (p: true) # all packages are ok
(import ./default.nix { pkgs = super; }) (import ./default.nix { pkgs = super; })