Skip to content

How do you use --run with flakes? #427

@austinbutler

Description

@austinbutler

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions