mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/tests: add nixos-rebuild-target-host-ng
This commit is contained in:
parent
1d3c452d63
commit
1b5fac463b
3 changed files with 31 additions and 6 deletions
|
@ -720,7 +720,14 @@ in {
|
||||||
imports = [ ./nixos-rebuild-specialisations.nix ];
|
imports = [ ./nixos-rebuild-specialisations.nix ];
|
||||||
_module.args.withNg = true;
|
_module.args.withNg = true;
|
||||||
};
|
};
|
||||||
nixos-rebuild-target-host = runTest ./nixos-rebuild-target-host.nix;
|
nixos-rebuild-target-host = runTest {
|
||||||
|
imports = [ ./nixos-rebuild-target-host.nix ];
|
||||||
|
_module.args.withNg = false;
|
||||||
|
};
|
||||||
|
nixos-rebuild-target-host-ng = runTest {
|
||||||
|
imports = [ ./nixos-rebuild-target-host.nix ];
|
||||||
|
_module.args.withNg = true;
|
||||||
|
};
|
||||||
nixpkgs = pkgs.callPackage ../modules/misc/nixpkgs/test.nix { inherit evalMinimalConfig; };
|
nixpkgs = pkgs.callPackage ../modules/misc/nixpkgs/test.nix { inherit evalMinimalConfig; };
|
||||||
nixseparatedebuginfod = handleTest ./nixseparatedebuginfod.nix {};
|
nixseparatedebuginfod = handleTest ./nixseparatedebuginfod.nix {};
|
||||||
node-red = handleTest ./node-red.nix {};
|
node-red = handleTest ./node-red.nix {};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ hostPkgs, ... }: {
|
{ hostPkgs, lib, withNg, ... }: {
|
||||||
name = "nixos-rebuild-target-host";
|
name = "nixos-rebuild-target-host";
|
||||||
|
|
||||||
# TODO: remove overlay from nixos/modules/profiles/installation-device.nix
|
# TODO: remove overlay from nixos/modules/profiles/installation-device.nix
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
system.build.publicKey = snakeOilPublicKey;
|
system.build.publicKey = snakeOilPublicKey;
|
||||||
# We don't switch on `deployer`, but we need it to have the dependencies
|
# We don't switch on `deployer`, but we need it to have the dependencies
|
||||||
# available, to be picked up by system.includeBuildDependencies above.
|
# available, to be picked up by system.includeBuildDependencies above.
|
||||||
|
system.rebuild.enableNg = withNg;
|
||||||
system.switch.enable = true;
|
system.switch.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@
|
||||||
targetNetworkJSON = hostPkgs.writeText "target-network.json"
|
targetNetworkJSON = hostPkgs.writeText "target-network.json"
|
||||||
(builtins.toJSON nodes.target.system.build.networkConfig);
|
(builtins.toJSON nodes.target.system.build.networkConfig);
|
||||||
|
|
||||||
configFile = hostname: hostPkgs.writeText "configuration.nix" ''
|
configFile = hostname: hostPkgs.writeText "configuration.nix" /* nix */ ''
|
||||||
{ lib, modulesPath, ... }: {
|
{ lib, modulesPath, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/virtualisation/qemu-vm.nix")
|
(modulesPath + "/virtualisation/qemu-vm.nix")
|
||||||
|
@ -100,12 +101,24 @@
|
||||||
forceInstall = true;
|
forceInstall = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.rebuild.enableNg = ${lib.boolToString withNg};
|
||||||
|
|
||||||
|
${lib.optionalString withNg /* nix */ ''
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
# Set tmpdir inside nixos-rebuild-ng to test
|
||||||
|
# "Deploy works with very long TMPDIR"
|
||||||
|
nixos-rebuild-ng = prev.nixos-rebuild-ng.override { withTmpdir = "/tmp"; };
|
||||||
|
})
|
||||||
|
];
|
||||||
|
''}
|
||||||
|
|
||||||
# this will be asserted
|
# this will be asserted
|
||||||
networking.hostName = "${hostname}";
|
networking.hostName = "${hostname}";
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
''
|
/* python */ ''
|
||||||
start_all()
|
start_all()
|
||||||
target.wait_for_open_port(22)
|
target.wait_for_open_port(22)
|
||||||
|
|
||||||
|
@ -137,7 +150,8 @@
|
||||||
assert target_hostname == "config-2-deployed", f"{target_hostname=}"
|
assert target_hostname == "config-2-deployed", f"{target_hostname=}"
|
||||||
|
|
||||||
with subtest("Deploy to bob@target with password based sudo"):
|
with subtest("Deploy to bob@target with password based sudo"):
|
||||||
deployer.succeed("passh -c 3 -C -p ${nodes.target.users.users.bob.password} -P \"\[sudo\] password\" nixos-rebuild switch -I nixos-config=/root/configuration-3.nix --target-host bob@target --use-remote-sudo &>/dev/console")
|
# TODO: investigate why --ask-sudo-password from nixos-rebuild-ng is not working here
|
||||||
|
deployer.succeed(r'${lib.optionalString withNg "NIX_SSHOPTS=-t "}passh -c 3 -C -p ${nodes.target.users.users.bob.password} -P "\[sudo\] password" nixos-rebuild switch -I nixos-config=/root/configuration-3.nix --target-host bob@target --use-remote-sudo &>/dev/console')
|
||||||
target_hostname = deployer.succeed("ssh alice@target cat /etc/hostname").rstrip()
|
target_hostname = deployer.succeed("ssh alice@target cat /etc/hostname").rstrip()
|
||||||
assert target_hostname == "config-3-deployed", f"{target_hostname=}"
|
assert target_hostname == "config-3-deployed", f"{target_hostname=}"
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,11 @@ python3Packages.buildPythonApplication rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
tests = {
|
tests = {
|
||||||
inherit (nixosTests) nixos-rebuild-install-bootloader-ng nixos-rebuild-specialisations-ng;
|
inherit (nixosTests)
|
||||||
|
nixos-rebuild-install-bootloader-ng
|
||||||
|
nixos-rebuild-specialisations-ng
|
||||||
|
nixos-rebuild-target-host-ng
|
||||||
|
;
|
||||||
repl = callPackage ./tests/repl.nix { };
|
repl = callPackage ./tests/repl.nix { };
|
||||||
# NOTE: this is a passthru test rather than a build-time test because we
|
# NOTE: this is a passthru test rather than a build-time test because we
|
||||||
# want to keep the build closures small
|
# want to keep the build closures small
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue