lib/filterPackages: filter by flake requirements

returns only non-broken derivations that support the system.
This commit is contained in:
Pacman99 2021-03-26 14:41:10 -07:00
parent 4f38a88191
commit fb14e20249
2 changed files with 11 additions and 1 deletions

View file

@ -26,4 +26,13 @@ rec {
});
concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { };
# Filter out packages that support given system and follow flake check requirements
filterPackages = system: packages:
let
# Everything that nix flake check requires for the packages output
filter = (n: v: with v; let platforms = meta.hydraPlatforms or meta.platforms or [ ]; in
lib.isDerivation v && !meta.broken && builtins.elem system platforms);
in
lib.filterAttrs filter packages;
}

View file

@ -17,7 +17,8 @@ lib.makeExtensible (final:
lists = callLibs ./lists.nix;
strings = callLibs ./strings.nix;
inherit (attrs) mapFilterAttrs genAttrs' pathsToImportedAttrs concatAttrs;
inherit (attrs) mapFilterAttrs genAttrs'
pathsToImportedAttrs concatAttrs filterPackages;
inherit (lists) pathsIn;
inherit (strings) rgxToString;
})