From f5116b0f4daa738e8421860d5f4fb8ca4c402678 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Wed, 2 Jan 2019 20:19:23 +0100 Subject: [PATCH] nix-gc: add user option This configures the user that runs the garbage collector, particularly useful for single-user installs. Otherwise it runs as root resulting in permission issues afterwards. --- modules/services/nix-gc/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/services/nix-gc/default.nix b/modules/services/nix-gc/default.nix index b96a8549..ca4a0ab1 100644 --- a/modules/services/nix-gc/default.nix +++ b/modules/services/nix-gc/default.nix @@ -14,6 +14,12 @@ in description = "Automatically run the garbage collector at a specific time."; }; + nix.gc.user = mkOption { + type = types.nullOr types.str; + default = null; + description = "User that runs the garbage collector."; + }; + nix.gc.interval = mkOption { type = types.attrs; default = { Hour = 3; Minute = 15; }; @@ -38,6 +44,7 @@ in environment.NIX_REMOTE = optionalString config.services.nix-daemon.enable "daemon"; serviceConfig.RunAtLoad = false; serviceConfig.StartCalendarInterval = [ cfg.interval ]; + serviceConfig.UserName = cfg.user; }; };