anchor.diff:  
     # The configuration to install.
     makeConfig = { grubVersion, grubDevice, grubIdentifier
  -               , extraConfig, readOnly ? true, forceGrubReinstallCount ? 0
  +               , extraConfig, forceGrubReinstallCount ? 0
                  }:
       pkgs.writeText "configuration.nix" ''
         { config, lib, pkgs, modulesPath, ... }:
  
positive.code:         boot.loader.grub.fsIdentifier = "${grubIdentifier}";
  
          boot.loader.grub.configurationLimit = 100 + ${toString forceGrubReinstallCount};
  
          ${optionalString (!readOnly) "nix.readOnlyStore = false;"}
  
          hardware.enableAllFirmware = lib.mkForce false;
  
  
negative.code: 
        # We need to a writable nix-store on next boot.
        $machine->copyFileFromHost(
            "${ makeConfig { inherit grubVersion grubDevice grubIdentifier extraConfig; forceGrubReinstallCount = 1; } }",
            "/etc/nixos/configuration.nix");
  
        # Check whether nixos-rebuild works.
  