Can't make a bootable qemu-efi with nixos-generators

Hello,

I’ve failed for the past few hours to make a bootable NixOS with nixos-generators and qemu-efi.

Where am I going wrong? Please can you point me in the right direction.

I can get to grub, select the only option, and then get

EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path

I’ve checked with a live disk that vda1 is EFI and has kernels with bzImage and initrd files. The grub menu references these. vda2 is root. No other partitions. This looks right as defined by qemu-efi

Build host & hypervisor host are the same x86_64 NixOS system.

flake.nix

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = {
    self,
    nixpkgs,
    nixos-generators,
    ...
  }: {
    packages.x86_64-linux = {
      qemu = nixos-generators.nixosGenerate {
        system = "x86_64-linux";
        format = "qcow-efi";
        modules = [
          ./configuration.nix
        ];
      };
    };
  };
}

configuration.nix

{
  lib,
  modulesPath,
  ...
}: {
  imports = [(modulesPath + "/profiles/qemu-guest.nix")];
  boot.loader.timeout = lib.mkForce 30;

  users = {
    users.xxxxx = {
      hashedPassword = "xxxxxxxxxxxxxxx";
      openssh.authorizedKeys.keys = [
        "ssh-ed25519 xxxxxxxxxxxxxxxxxxxxxxxxxx"
      ];
      isNormalUser = true;
      group = "xxxxx";
      extraGroups = ["wheel"];
    };
    groups.xxxxx = {};
  };

  services.openssh.enable = true;

  system.stateVersion = "23.11"; # Because I plan on pulling in other config which is 23.11
}

In virt-manager I am setting it up as EFI

vm.xml

  <os>
    <type arch="x86_64" machine="pc-q35-8.2">hvm</type>
    <loader readonly="yes" type="pflash">/run/libvirt/nix-ovmf/OVMF_CODE.fd</loader>
    <nvram template="/run/libvirt/nix-ovmf/OVMF_VARS.fd">/var/lib/libvirt/qemu/nvram/nixos-24.05-3_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>
...
  <devices>
    <emulator>/run/libvirt/nix-emulators/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/nix/store/gga59yym85h4fr740klxlvbqhyq7q36s-nixos-disk-image/nixos.qcow2"/>
      <target dev="vda" bus="virtio"/>
      <readonly/>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </disk>
...

Grub boot option

Disk mounted in livecd

Disks in grub cli