[Backport staging-nixos-26.05] nixos/tests: Load root profile in nspawn tests (#534851)

This commit is contained in:
Martin Weinelt
2026-06-24 11:42:16 +00:00
committed by GitHub
2 changed files with 9 additions and 4 deletions

View File

@@ -1586,7 +1586,7 @@ class NspawnMachine(BaseMachine):
# NOTE If the test calls switch-to-configuration (with a differently configured specialization)
# this will use the /etc/profile of the new specialisation while `QemuMachine` nodes
# will continue to use the original /etc/profile.
command = f"set -eo pipefail; source /etc/profile; set -u; {command}"
command = f"set -eo pipefail; USER=root HOME=/root source /etc/profile; set -u; {command}"
cp = subprocess.run(
[

View File

@@ -1,11 +1,16 @@
{
name = "simple-container";
containers.machine = { };
containers = {
machine = { pkgs, ... }: {
users.users.root.packages = [ pkgs.hello ];
};
noprofile = { };
};
testScript = ''
start_all()
machine.wait_for_unit("multi-user.target")
machine.shutdown()
machine.succeed("hello")
noprofile.fail("hello")
'';
}