From fb14e20249fd58facfc4819fa9fac4d75db1893f Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Fri, 26 Mar 2021 14:41:10 -0700 Subject: [PATCH 1/2] lib/filterPackages: filter by flake requirements returns only non-broken derivations that support the system. --- lib/attrs.nix | 9 +++++++++ lib/default.nix | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/attrs.nix b/lib/attrs.nix index 534a9918..dbc44b5f 100644 --- a/lib/attrs.nix +++ b/lib/attrs.nix @@ -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; } diff --git a/lib/default.nix b/lib/default.nix index 7fceb3ce..2ff31023 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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; }) From 58814fe74109b7725aa6466e9620a61920d0f508 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Fri, 26 Mar 2021 16:33:27 -0700 Subject: [PATCH 2/2] flake: use filterPackages instead of flattenTreeSystem --- flake.lock | 7 +++---- flake.nix | 12 ++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index 3bf8a9ec..da0f2bc6 100644 --- a/flake.lock +++ b/flake.lock @@ -260,16 +260,15 @@ }, "utils": { "locked": { - "lastModified": 1608663846, - "narHash": "sha256-YOAXeoNLW0IubQ6AZLGuSj5kAD5n4DYXLYReLtyds1A=", + "lastModified": 1614513358, + "narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=", "owner": "numtide", "repo": "flake-utils", - "rev": "a68df93a37cd5137ac22ffeb2d8a03acf253cc24", + "rev": "5466c5bbece17adaab2d82fae80b46e807611bf3", "type": "github" }, "original": { "owner": "numtide", - "ref": "flatten-tree-system", "repo": "flake-utils", "type": "github" } diff --git a/flake.nix b/flake.nix index 082f501a..8f899d9d 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; }; @@ -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 @@ -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;