Flake-parts perSystem packages systems question

In flake-parts, packages can be put in perSystem block, so all the packages inside are able to build with the systems define in the systems list.

But what should I do if not all the packages can be build with all the systems in the systems list?

For example, say I have 26 packages in the flake named A-Z:
packages.A to packages.G can build with systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]
packages.H to packages.P can only build with systems = [ "x86_64-linux" ]
packages.Q to packages.Z can only build with systems = [ "x86_64-linux" "aarch64-linux" ]

If all the packages are put in perSystem and set systems list to all architecture, running nix flake check on an aarch64-linux machine just failed on packages.H.

What is the best way to handle this in flake-parts?

You can conditionally choose whether to add the packages based on the value of system in the perSystem block.

You can see I base the filtering process on the meta attribute of the packages themselves, in my config:

That way it follows the meta.platforms I set in the package definitions.

1 Like

This is genius!!!

1 Like