I would like to generate a flake top level that is defined like this (very simplified to try and focus on my specific question) mapping doesn’t seem to work very well primarily because it’s return result is a list of containing all the variations instead of an actual attribute set.
mkFlake inputs {
systems = [ "x86_64-linux" "another-architecture" ];
devShells.default = pkgs: pkgs.mkShellNoCC {
buildInputs = with pkgs; [ alejandra nixd ] ;
};
}
But it’s actual return result is this
{
devShells.86_64-linux.default = { ... };
devShells.another-architecture = { ... };
}
Here is my current mkFlake implementation, I’ve stripped it down to just focus on this specific question initially.
{lib}: {
mkFlake = {
self,
nixpkgs ? inputs.nixpkgs,
...
} @ inputs: {
devShells ? {},
systems,
...
} @ flake: let
b = builtins;
inherit (lib.attrsets) mapAttrs filterAttrs;
perSystemAttributes = b.map (system: let
pkgs = import nixpkgs {
inherit system;
};
in
filterAttrs (_: v: v.${system} != {}) {
devShells.${system} = mapAttrs (_: v: v pkgs) devShells;
}) systems;
in
perSystemAttributes;
}