nixos/nix-daemon: Set HOME for unprivileged daemon

Fixes issues with fetching from substituter while running with an
unprivileged daemon.

Using the StateDirectory instead of CacheDirectory here since it is
unclear what Nix will store there in the future.
This commit is contained in:
Artemis Tosini
2026-08-04 10:47:17 -04:00
parent 41ee31dd17
commit dfca7cafbb
@@ -102,10 +102,14 @@ in
systemd.services.nix-daemon = {
# Nix assumes it should use `daemon` if it isn't root, so we have to set `NIX_REMOTE` anyway
environment.NIX_REMOTE = "local?use-roots-daemon=true";
# Nix wants a HOME it can access to cache substituter contents, among other things.
environment.HOME = "%S/nix-daemon";
serviceConfig = {
User = cfg.daemonUser;
Group = cfg.daemonGroup;
StateDirectory = "nix-daemon";
# Empty string needed to disable old Exec
ExecStart = [
""