forked from pub-solar/os
Merge #220
220: Drop flattenTreeSystem and use custom function for filtering packages r=nrdxp a=Pacman99 I don't think we should flatten the system because if a user doesn't make a package a derivation in pkgs/default.nix we should trust that there is a reason for doing so. So instead this drops the flattenTreeSystem reference(and switches to flake-utils master branch) and replaces its usage with a custom function `filterPackages`. This function filter all packages that match three conditions; - is a derivation - not broken - system is supported In that order as to not cause errors when trying to reference non-derivation meta attributes. And then also just dump *all* packages into legacy packages, so everything else is still accessible. I was considering removing the packages that are already in the packages output in legacyPackages, but I don't think its necessary since nix looks to the packages output first. Co-authored-by: Pacman99 <pachum99@gmail.com>
This commit is contained in:
commit
5a3bae7be5
|
@ -260,16 +260,15 @@
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1608663846,
|
"lastModified": 1614513358,
|
||||||
"narHash": "sha256-YOAXeoNLW0IubQ6AZLGuSj5kAD5n4DYXLYReLtyds1A=",
|
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "a68df93a37cd5137ac22ffeb2d8a03acf253cc24",
|
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"ref": "flatten-tree-system",
|
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
12
flake.nix
12
flake.nix
|
@ -23,7 +23,7 @@
|
||||||
naersk.url = "github:nmattia/naersk";
|
naersk.url = "github:nmattia/naersk";
|
||||||
naersk.inputs.nixpkgs.follows = "override";
|
naersk.inputs.nixpkgs.follows = "override";
|
||||||
nixos-hardware.url = "github:nixos/nixos-hardware";
|
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.url = "path:./pkgs";
|
||||||
pkgs.inputs.nixpkgs.follows = "nixos";
|
pkgs.inputs.nixpkgs.follows = "nixos";
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
systemOutputs = utils.lib.eachDefaultSystem (system:
|
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 =
|
checks =
|
||||||
let
|
let
|
||||||
|
@ -82,8 +86,8 @@
|
||||||
in
|
in
|
||||||
nixos.lib.recursiveUpdate tests deployChecks;
|
nixos.lib.recursiveUpdate tests deployChecks;
|
||||||
|
|
||||||
packages = utils.lib.flattenTreeSystem system
|
inherit legacyPackages;
|
||||||
(os.mkPackages { inherit pkgs; });
|
packages = lib.filterPackages system legacyPackages;
|
||||||
|
|
||||||
devShell = import ./shell {
|
devShell = import ./shell {
|
||||||
inherit self system;
|
inherit self system;
|
||||||
|
|
|
@ -28,4 +28,13 @@ rec {
|
||||||
});
|
});
|
||||||
|
|
||||||
concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { };
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ lib.makeExtensible (final:
|
||||||
lists = callLibs ./lists.nix;
|
lists = callLibs ./lists.nix;
|
||||||
strings = callLibs ./strings.nix;
|
strings = callLibs ./strings.nix;
|
||||||
|
|
||||||
inherit (attrs) mapFilterAttrs genAttrs' pathsToImportedAttrs concatAttrs;
|
inherit (attrs) mapFilterAttrs genAttrs'
|
||||||
|
pathsToImportedAttrs concatAttrs filterPackages;
|
||||||
inherit (lists) pathsIn;
|
inherit (lists) pathsIn;
|
||||||
inherit (strings) rgxToString;
|
inherit (strings) rgxToString;
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue