From dfca7cafbbe14c4d6ccf142eb80d55e2f7cccc5c Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Tue, 4 Aug 2026 10:47:17 -0400 Subject: [PATCH] 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. --- nixos/modules/services/system/nix-daemon.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/modules/services/system/nix-daemon.nix b/nixos/modules/services/system/nix-daemon.nix index 97a5752bd35c..ab799c778a34 100644 --- a/nixos/modules/services/system/nix-daemon.nix +++ b/nixos/modules/services/system/nix-daemon.nix @@ -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 = [ ""