nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

How do you use `--run` with flakes?

Open austinbutler opened this issue 9 months ago • 0 comments

I have a working build using the "Using in a Flake" section of the README. I can run nix build .#/installer-iso and it writes an ISO file out in result. There's also a --run option for nixos-generate, but when I use that I get an attribute missing error.

❯ nixos-generate --flake .\#installer-iso --format vm-nogui
fetching git input 'git+file:///home/austin/Documents/nixos'
error:
       … while evaluating 'flakeSystem' to select 'extendModules' on it
         at /nix/store/1r44k5dmzlz8132918hflmmww6x608im-nixos-generators-1.8.0/share/nixos-generator/nixos-generate.nix:17:5:
           16|   then
           17|     flakeSystem.extendModules {
             |     ^
           18|       modules = [module formatConfig];

       … while evaluating the attribute 'outputs.packages.x86_64-linux.nixosConfigurations.installer-iso'
         at /nix/store/hmalhgqw856pybjgbzvffi26sf2fmcyp-source/flake.nix:415:7:
          414|       };
          415|       packages.x86_64-linux = {
             |       ^
          416|         installer-iso = inputs.nixos-generators.nixosGenerate {

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'installer-iso' missing
       at /nix/store/1r44k5dmzlz8132918hflmmww6x608im-nixos-generators-1.8.0/share/nixos-generator/nixos-generate.nix:13:90:
           12|   flake = builtins.getFlake flakeUri;
           13|   flakeSystem = flake.outputs.packages."${system}".nixosConfigurations."${flakeAttr}" or flake.outputs.nixosConfigurations."${flakeAttr}";
             |                                                                                          ^
           14| in
❯ nixos-generate --flake .\#packages.x86_64-linux.installer-iso --format vm-nogui
fetching git input 'git+file:///home/austin/Documents/nixos'
error:
       … while evaluating 'flakeSystem' to select 'extendModules' on it
         at /nix/store/1r44k5dmzlz8132918hflmmww6x608im-nixos-generators-1.8.0/share/nixos-generator/nixos-generate.nix:17:5:
           16|   then
           17|     flakeSystem.extendModules {
             |     ^
           18|       modules = [module formatConfig];

       … while evaluating the attribute 'outputs.packages.x86_64-linux.nixosConfigurations."packages.x86_64-linux.installer-iso"'
         at /nix/store/hmalhgqw856pybjgbzvffi26sf2fmcyp-source/flake.nix:415:7:
          414|       };
          415|       packages.x86_64-linux = {
             |       ^
          416|         installer-iso = inputs.nixos-generators.nixosGenerate {

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute '"packages.x86_64-linux.installer-iso"' missing
       at /nix/store/1r44k5dmzlz8132918hflmmww6x608im-nixos-generators-1.8.0/share/nixos-generator/nixos-generate.nix:13:90:
           12|   flake = builtins.getFlake flakeUri;
           13|   flakeSystem = flake.outputs.packages."${system}".nixosConfigurations."${flakeAttr}" or flake.outputs.nixosConfigurations."${flakeAttr}";
             |                                                                                          ^
           14| in

Is it expecting that you're using the "Using as a nixos-module" section of the README?

austinbutler avatar Mar 09 '25 05:03 austinbutler