nixos/tests: Load root profile in nspawn tests

This is currently a hacky workarround, but bettern than nothing until we come up
with a better solution.
This commit is contained in:
Nina Fromm 2026-06-22 17:35:25 +02:00 committed by Kierán Meinhardt
commit 0dc4ca4c71
2 changed files with 9 additions and 4 deletions

View file

@ -1587,7 +1587,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")
'';
}