1
1
mirror of https://github.com/divnix/digga.git synced 2024-11-27 09:29:27 +03:00

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;
})