I have a flake containing my NixOS and HomeManager configurations, but I also wanted to add some shells I commonly use, such as a rust shell. I wanted to use a forAllSystems function to create an attribute set for each shell and avoid adding another flake input to do this for me. I’ve been struggling to get it working and most recently have been getting the error “error: flake output attribute ‘devShells.x86_64-linux.rust’ is not a derivation”
The relevant code snippets look like this
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsForSystem = system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = inputOverlays ++ [ localOverlays ];
};
in
{
devShells = forAllSystems (system:
import ./shells { pkgs = pkgsForSystem system;}
);
}
shells/default.nix
{ pkgs, ... }:
{
rust = ./rust.nix;
}
It works fine if I simply use devShells."x86_64-linux".rust = import ./shells/rust.nix { pkgs = pkgsForSystem "x86_64-linux"; };
, so I know the issue is with my function, but I’m not sure what it is.