anchor.diff:          # A writable boot disk can be booted from automatically.
           ${qemu}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1
   
  +        NIX_EFI_VARS=$(readlink -f ''${NIX_EFI_VARS:-${cfg.efiVars}})
  +
           ${if cfg.useEFIBoot then ''
             # VM needs writable EFI vars
  -          cp ${bootDisk}/EFI_VARS.fd $TMPDIR || exit 1
  -          chmod 0644 $TMPDIR/EFI_VARS.fd || exit 1
  +          if ! test -e "$NIX_EFI_VARS"; then
  +            cp ${bootDisk}/efi-vars.fd "$NIX_EFI_VARS" || exit 1
  +            chmod 0644 "$NIX_EFI_VARS" || exit 1
  +          fi
           '' else ''
           ''}
         '' else ''
  
positive.code:     else if pkgs.stdenv.isAarch64 then "${pkgs.OVMF.fd}/FV/AAVMF"
      else throw "No EFI firmware available for platform";
    efiFirmware = "${efiPrefix}_CODE.fd";
    efiVars = "${efiPrefix}_VARS.fd";
  
    # Shell script to start the VM.
    startVM =
  
negative.code:           '';
        };
  
      virtualisation.efiVars =
        mkOption {
          default = "./${vmName}-efi-vars.fd";
          description =
            ''
              Path to nvram image containing UEFI variables.  The will be created
              on startup if it does not exist.
            '';
        };
  
      virtualisation.bios =
        mkOption {
          default = null;
  