Fix failing darwin tests

Some tests were failing on darwin,
if the auto-allocate-uids featrure was enabled.
This was because AAU on darwin works by setuid-ing as a non-existent
user, so the tests that were relying on `whoami` were failing.

In the case of trusted-users we fall back to printing the user id,
which is already handled gracefully in the daemon code - i.e. when
a user does not exist or for some other reason looking up their
username is not possible, the daemon falls back to searching for their
uid inside the trusted-users list.

When whoami is used to print the username for other purpose,
we default to printing nixbld.

Change-Id: Ib61615677565098cb5fbf5e26a946ef427c58caf
This commit is contained in:
Nikodem Rabuliński 2024-05-06 18:13:15 +02:00
parent 106b959043
commit 83a2cd0c46
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -2,7 +2,7 @@ source common.sh
sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > $TEST_ROOT/nix-profile.sh sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > $TEST_ROOT/nix-profile.sh
user=$(whoami) user=$(whoami || echo -n nixbld)
rm -rf $TEST_HOME $TEST_ROOT/profile-var rm -rf $TEST_HOME $TEST_ROOT/profile-var
mkdir -p $TEST_HOME mkdir -p $TEST_HOME
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set" USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set"

View file

@ -28,7 +28,7 @@ substituters =
flake-registry = $TEST_ROOT/registry.json flake-registry = $TEST_ROOT/registry.json
show-trace = true show-trace = true
include nix.conf.extra include nix.conf.extra
trusted-users = $(whoami) trusted-users = $(whoami || id -u)
EOF EOF
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF