nixosTests.nix-upgrade: fix failing test

The test currently fails because we attempt to switch to a NixOS
configuration that is _very_ different from the one we are switching
from (e.g. the new configuration has an entirely empty /etc/fstab,
causing switch-to-configuration to want to start unmounting all
filesystems defined in the old configuration).
This commit is contained in:
Jared Baur 2024-10-05 09:51:28 -07:00
parent a6c47dcae2
commit c2621cb78a
No known key found for this signature in database

View File

@ -7,17 +7,6 @@ let
${pkgs.system} = "${nixVersions.latest}"; ${pkgs.system} = "${nixVersions.latest}";
}''; }'';
inputDrv = import ../.. {
configuration = {
imports = [ nixos-module ];
nix.package = nixVersions.latest;
boot.isContainer = true;
users.users.alice.isNormalUser = true;
};
system = pkgs.system;
};
nixos-module = builtins.toFile "nixos-module.nix" '' nixos-module = builtins.toFile "nixos-module.nix" ''
{ lib, pkgs, modulesPath, ... }: { lib, pkgs, modulesPath, ... }:
{ {
@ -53,8 +42,13 @@ pkgs.testers.nixosTest {
nix.package = nixVersions.stable; nix.package = nixVersions.stable;
system.extraDependencies = [ system.extraDependencies = [
fallback-paths-external fallback-paths-external
inputDrv.system
]; ];
specialisation.newer-nix.configuration = {
nix.package = lib.mkForce nixVersions.latest;
users.users.alice.isNormalUser = true;
};
}; };
testScript = '' testScript = ''
@ -91,7 +85,7 @@ pkgs.testers.nixosTest {
with subtest("upgrade-via-switch-to-configuration"): with subtest("upgrade-via-switch-to-configuration"):
# not using nixos-rebuild due to nix-instantiate being called and forcing all drv's to be rebuilt # not using nixos-rebuild due to nix-instantiate being called and forcing all drv's to be rebuilt
print(machine.succeed("${inputDrv.system.outPath}/bin/switch-to-configuration switch")) print(machine.succeed("/run/current-system/specialisation/newer-nix/bin/switch-to-configuration switch"))
result = machine.succeed("nix --version") result = machine.succeed("nix --version")
print(result) print(result)