Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop flattenTreeSystem and use custom function for filtering packages #220

Merged
merged 2 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
naersk.url = "github:nmattia/naersk";
naersk.inputs.nixpkgs.follows = "override";
nixos-hardware.url = "github:nixos/nixos-hardware";
utils.url = "github:numtide/flake-utils/flatten-tree-system";
utils.url = "github:numtide/flake-utils";
pkgs.url = "path:./pkgs";
pkgs.inputs.nixpkgs.follows = "nixos";
};
Expand Down Expand Up @@ -70,7 +70,11 @@
};

systemOutputs = utils.lib.eachDefaultSystem (system:
let pkgs = multiPkgs.${system}; in
let
pkgs = multiPkgs.${system};
# all packages that are defined in ./pkgs
legacyPackages = os.mkPackages { inherit pkgs; };
in
{
checks =
let
Expand All @@ -82,8 +86,8 @@
in
nixos.lib.recursiveUpdate tests deployChecks;

packages = utils.lib.flattenTreeSystem system
(os.mkPackages { inherit pkgs; });
inherit legacyPackages;
packages = lib.filterPackages system legacyPackages;

devShell = import ./shell {
inherit self system;
Expand Down
9 changes: 9 additions & 0 deletions lib/attrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})