From 019697db058b6738eda0cb2cdcc9f5c014c914cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 6 Feb 2026 17:04:19 +0100 Subject: [PATCH] nixos/test-driver: document implications of sourcing /etc/profile with nspawn machines --- nixos/lib/test-driver/src/test_driver/machine/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/src/test_driver/machine/__init__.py b/nixos/lib/test-driver/src/test_driver/machine/__init__.py index 52ab43b6d79d..664b2aae3906 100644 --- a/nixos/lib/test-driver/src/test_driver/machine/__init__.py +++ b/nixos/lib/test-driver/src/test_driver/machine/__init__.py @@ -1484,8 +1484,14 @@ class NspawnMachine(BaseMachine): nsenter = shutil.which("nsenter") assert nsenter is not None - # Pull in /etc/profile, and some shell sanity. + # Sourcing /etc/profile on every call of `_execute` ensures a correct shell + # environment (correct PATH, etc.). This is slower than the QEMU version. + # + # 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}" + cp = subprocess.run( [ nsenter,