-
Notifications
You must be signed in to change notification settings - Fork 79
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
featreq: function to filter out overlay packages for supported platforms #4
Comments
{
packages = let
pkgs = sys:
let
nixpkgs_ = (pkgsFor inputs.nixpkgs sys true);
packagePlatforms = pkg: pkg.meta.hydraPlatforms or pkg.meta.platforms or [ "x86_64-linux" ];
pred = n: v: builtins.elem sys (packagePlatforms v);
in
nixpkgs_.lib.filterAttrs pred nixpkgs_.waylandPkgs;
in {
x86_64-linux = pkgs "x86_64-linux";
aarch64-linux = pkgs "aarch64-linux";
};
} |
With today's flake-utils you would achieve something similar like this: {
description = "colemicken's wayland overlay";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
{
overlay = import ./overlay.nix;
}
//
(
flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
config = { };
overlays = [ self.overlay ];
};
in
{
packages = pkgs.waylandPkgs;
}
)
);
} Assuming that the overlay puts all its packages under The big chunk at the end could probably be simplified for the common case. {
description = "colemicken's wayland overlay";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.simpleFlake {
inherit self nixpkgs;
overlay = import ./overlay.nix;
overlayAttr = "waylandPkgs";
systems = [ "aarch64-linux" "x86_64-linux" ];
};
} How does that look? |
Looking forward to your feedback! |
I'm skimming through the source and #5, I'm not seeing anything that does the filtering I'm looking for based on the |
You're right. .flattenTree should be changed to take the system as an argument. Do you want to tackle this? |
I can't anytime soon. But cleaning up my flake.nixs will eventually block me and I plan to clean them via this repo, so I'll get to it eventually if you don't. Thanks for confirming my understanding and starting up this repo. |
We're slowly converting our overlays to flakes, and something that filters the per-system package set based on In our current overlays, we import |
^ please try out this new implementation in PR 13 |
@nrdxp do stars align here? (through PR13). I think My reasoning is: |
My solution does check the buildInputs of each flake package for platform dependence, but not recursively. |
This is what I'm doing now. I know there are more sophisticated versions around that will check dependencies recursively. This seems eligible for
flake-utils
, any overlay or package set providers will likely want to use some sort of function like this.(Bonus points if we discuss whether to filter unsupported platforms out entirely, or if we give a more helpful error in those cases.)
The text was updated successfully, but these errors were encountered: