diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 66ab2567e19..7cab313cec2 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -35,7 +35,8 @@ let # The configuration to install. - makeConfig = { testChannel, useEFI, grubVersion, grubDevice, grubIdentifier }: + makeConfig = { testChannel, useEFI, grubVersion, grubDevice, grubIdentifier + , readOnly ? true, forceGrubReinstallCount ? 0 }: pkgs.writeText "configuration.nix" '' { config, pkgs, modulesPath, ... }: @@ -57,6 +58,10 @@ let boot.loader.grub.fsIdentifier = "${grubIdentifier}"; ''} + boot.loader.grub.configurationLimit = 100 + ${toString forceGrubReinstallCount}; + + ${optionalString (!readOnly) "nix.readOnlyStore = false;"} + environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ]; } ''; @@ -198,6 +203,11 @@ let $machine->succeed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/ or die "nix-env failed"; + # We need to a writable nix-store on next boot + $machine->copyFileFromHost( + "${ makeConfig { inherit testChannel useEFI grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 1; } }", + "/etc/nixos/configuration.nix"); + # Check whether nixos-rebuild works. $machine->succeed("nixos-rebuild switch >&2"); @@ -208,6 +218,15 @@ let $machine->shutdown; + # Check whether a writable store build works + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + $machine->waitForUnit("multi-user.target"); + $machine->copyFileFromHost( + "${ makeConfig { inherit testChannel useEFI grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 2; } }", + "/etc/nixos/configuration.nix"); + $machine->succeed("nixos-rebuild boot >&2"); + $machine->shutdown; + # And just to be sure, check that the machine still boots after # "nixos-rebuild switch". $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });