diff --git a/default.nix b/default.nix
index 0916c82..c19e698 100644
--- a/default.nix
+++ b/default.nix
@@ -45,7 +45,7 @@ let
./modules/services/emacs.nix
./modules/services/mopidy.nix
./modules/services/nix-daemon.nix
- ./modules/services/nix-gc.nix
+ ./modules/services/nix-gc
./modules/services/postgresql
./modules/programs/bash.nix
./modules/programs/fish.nix
diff --git a/modules/examples/hydra.nix b/modules/examples/hydra.nix
index bbee108..e941c5f 100644
--- a/modules/examples/hydra.nix
+++ b/modules/examples/hydra.nix
@@ -18,20 +18,17 @@ with lib;
services.nix-daemon.enable = true;
+ nix.trustedUsers = [ "@hydra" ];
+
nix.extraOptions = ''
pre-build-hook =
'';
- environment.etc."per-user/lnl/.ssh/authorized_keys".text = concatStringsSep "\n"
+ nix.gc.automatic = true;
+ nix.gc.options = "--max-freed $((25 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | awk '{ print $4 }')))";
+
+ environment.etc."per-user/hydra/ssh/authorized_keys".text = concatStringsSep "\n"
[ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCVsc0pHGsskoayziMhA2e59bHPWe0bbKgusmqhuJFBGQ1BAk9UmPzKCWE3nCiV6CLD1+SygVkBjb06DYtc+94BnzviCa9qZtL0G4+2vhp6x8OvXh8xlf/eWw3k5MWlvu+kjJFpbW8wHWTiUqzH+uEeHklAosT0lFNjiIYd/Vs3JAezhUR62a6c7ZjWOd5F7ALGEKzOiwC4i37kSgGsIWNCbe0Ku7gyr718zhMGeyxax6saHhnkSpIB+7d6oHhKeiJSFMWctNmz1/qxXUPbxNaJvqgdKlVHhN+B7x/TIbkVr5pTC59Okx9LTcpflFIv79VT+Gf1K7VypZpSvJjG0xFRt8iDs1+ssWFBfvpo94vUbZ+ZwMDcBGR5iJeO41Gj5fYn5aaDl32RXfJ9Fkwael1L6pcXtkIc66jk+KQQpgoeNj8Y3Emntpqva/2AM41wDDvr5tKp5KhEKFLM95CoiWq+g88pZLcpqLK7wooDVqNkVUEbMaj9lBN0AzU9mcsIRGvTa6CmWAdBvwqS2fRZD97Oarqct9AWgb0X6mOUq9BJNi4i4xvjgnVkylLwtLUnibR/PeXMtkb9bv6BEZXNf5ACqxSjKXJyaIHI65I5TILCr5eEgaujgvmkREn6U3T1NZAUIeVe9aVYLqehYh79OHUBzggoHqidRrXBB/6zdg9UgQ=="
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCnubA1pRqlpoAXkZ1q5nwhqi1RY2z840wFLFDj7vAMSups9E2U8PNIVtuVYApZpkBWIpzD4GGbQTF5Itnu5uBpJswc2Yat9yGWO/guuVyXIaRoBIM0Pg1WBWcWsz+k4rNludu9UQ74FHqEiqZIuIuOcgV+RIZn8xQlGt2kUqN9TWboHhZz8Zhx7EtGSJH6MJRLn3mA/pPjOF6k1jiiFG1pVDuqBTZPANkelWYCWAJ46jCyhxXltWE/jkBYGc/XbB8yT7DFE1XC6TVsSEp68R9PhVG3yqxqY06sniEyduSoGt/TDr6ycERd93bvLElXFATes85YiFszeaUgayYSKwQPe0q7YeHMhIXL0UYJYaKVVgT9saFDiHDzde7kKe+NA+J4+TbIk7Y/Ywn0jepsYV13M7TyEqgqbu9fvVGF3JI9+4g0m1gAzHTa7n6iiAedtz+Pi79uCEpRD2hWSSoLWroyPlep8j1p2tygtFsrieePEukesoToCTwqg1Ejnjh+yKdtUbc6xpyRvl3hKeO8QbCpfaaVd27e4vE4lP2JMW6nOo8b0wlVXQIFe5K2zh52q1MSwhLAq6Kg8oPmgj0lru4IivmPc+/NVwd3Qj3E9ZB8LRfTesfbcxHrC8lF5dL/QpLMeLwebrwCxL19gI0kxmDIaUQuHSyP3B2z+EmBKcN/Xw=="
];
-
- launchd.daemons.nix-gc = {
- command = "${config.nix.package}/bin/nix-collect-garbage -d";
- environment.NIX_REMOTE = optionalString config.services.activate-system.enable "daemon";
- serviceConfig.KeepAlive = false;
- serviceConfig.ProcessType = "Background";
- serviceConfig.StartInterval = 86400;
- };
}
diff --git a/modules/services/nix-gc.nix b/modules/services/nix-gc.nix
deleted file mode 100644
index 0dc704b..0000000
--- a/modules/services/nix-gc.nix
+++ /dev/null
@@ -1,55 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
- cfg = config.nix.gc;
-in
-
-{
- options = {
- nix.gc = {
-
- automatic = mkOption {
- default = false;
- type = types.bool;
- description = "Automatically run the garbage collector at a specific time.";
- };
-
- # TODO: parse dates
- # dates = mkOption {
- # default = "03:15";
- # type = types.str;
- # description = ''
- # Specification (in the format described by
- # systemd.time
- # 5) of the time at
- # which the garbage collector will run.
- # '';
- # };
-
- options = mkOption {
- default = "";
- example = "--max-freed $((64 * 1024**3))";
- type = types.str;
- description = ''
- Options given to nix-collect-garbage when the
- garbage collector is run automatically.
- '';
- };
-
- };
- };
-
- config = mkIf cfg.automatic {
-
- launchd.daemons.nix-gc = {
- command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
- serviceConfig.RunAtLoad = false;
- serviceConfig.StartCalendarInterval = mkDefault
- [ { Hour = 3; Minute = 15; }
- ];
- };
-
- };
-}
diff --git a/modules/services/nix-gc/default.nix b/modules/services/nix-gc/default.nix
new file mode 100644
index 0000000..b96a854
--- /dev/null
+++ b/modules/services/nix-gc/default.nix
@@ -0,0 +1,44 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.nix.gc;
+in
+
+{
+ options = {
+ nix.gc.automatic = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Automatically run the garbage collector at a specific time.";
+ };
+
+ nix.gc.interval = mkOption {
+ type = types.attrs;
+ default = { Hour = 3; Minute = 15; };
+ description = "The time interval at which the garbage collector will run.";
+ };
+
+ nix.gc.options = mkOption {
+ type = types.str;
+ default = "";
+ example = "--max-freed $((64 * 1024**3))";
+ description = ''
+ Options given to nix-collect-garbage when the
+ garbage collector is run automatically.
+ '';
+ };
+ };
+
+ config = mkIf cfg.automatic {
+
+ launchd.daemons.nix-gc = {
+ command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
+ environment.NIX_REMOTE = optionalString config.services.nix-daemon.enable "daemon";
+ serviceConfig.RunAtLoad = false;
+ serviceConfig.StartCalendarInterval = [ cfg.interval ];
+ };
+
+ };
+}