anchor.diff:        ${preBootCommands}
         $machine->waitForUnit("multi-user.target");
         $machine->copyFileFromHost(
  -          "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier extraConfig; forceGrubReinstallCount = 2; } }",
  +          "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier grubUseEfi extraConfig; forceGrubReinstallCount = 2; } }",
             "/etc/nixos/configuration.nix");
         $machine->succeed("nixos-rebuild boot >&2");
         $machine->shutdown;
  
positive.code:   # disk, and then reboot from the hard disk.  It's parameterized with
    # a test script fragment `createPartitions', which must create
    # partitions and filesystems.
    testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice
                    , grubIdentifier, preBootCommands, extraConfig
                    }:
      let
        iface = if grubVersion == 1 then "ide" else "virtio";
        qemuFlags =
          (if system == "x86_64-linux" then "-m 768 " else "-m 512 ") +
          (optionalString (system == "x86_64-linux") "-cpu kvm64 ");
        hdFlags = ''hda => "vm-state-machine/machine.qcow2", hdaInterface => "${iface}", ''
          + optionalString (bootLoader == "systemd-boot") ''bios => "${pkgs.OVMF.fd}/FV/OVMF.fd", '';
      in
      ''
        $machine->start;
  
negative.code:           ${optionalString (grubVersion == 1) ''
              boot.loader.grub.splashImage = null;
            ''}
  
            boot.loader.grub.extraConfig = "serial; terminal_output.serial";
            ${if grubUseEfi then ''
              boot.loader.grub.device = "nodev";
              boot.loader.grub.efiSupport = true;
              boot.loader.grub.efiInstallAsRemovable = true; # XXX: needed for OVMF?
            '' else ''
              boot.loader.grub.device = "${grubDevice}";
              boot.loader.grub.fsIdentifier = "${grubIdentifier}";
            ''}
  
            boot.loader.grub.configurationLimit = 100 + ${toString forceGrubReinstallCount};
          ''}
  