about summary refs log tree commit diff
path: root/ops/machines/whitby/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-04-14T16·16+0200
committertazjin <mail@tazj.in>2021-04-14T19·37+0000
commitcc903bc3b045486af514b03d61102eea4db69bd4 (patch)
tree87c7d14fd62c5361fac6a6b204256530bf0250ad /ops/machines/whitby/default.nix
parent605302091d6f35f6c6cd56170fde1c932cdb28ee (diff)
feat(ops/modules): Add module for automatically collecting garbage r/2511
Adds a module that automatically collects garbage based on disk space
thresholds, and configures it to run hourly on whitby.

This is implemented as an alternative to cl/2937, which I've been told
uses a Nix feature that doesn't actually work.

Under-the-hood this is simply a systemd timer running a shell script
which checks available disk space and runs GC when necessary.

Change-Id: I3c6b5de85b74ea52e7e16c53f2f900e0911c9805
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3014
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
Diffstat (limited to 'ops/machines/whitby/default.nix')
-rw-r--r--ops/machines/whitby/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/ops/machines/whitby/default.nix b/ops/machines/whitby/default.nix
index b2d3eca446..56cf2beab5 100644
--- a/ops/machines/whitby/default.nix
+++ b/ops/machines/whitby/default.nix
@@ -6,6 +6,7 @@ let
   inherit (lib) range;
 in {
   imports = [
+    "${depot.path}/ops/modules/automatic-gc.nix"
     "${depot.path}/ops/modules/clbot.nix"
     "${depot.path}/ops/modules/irccat.nix"
     "${depot.path}/ops/modules/monorepo-gerrit.nix"
@@ -187,6 +188,15 @@ in {
     challengeResponseAuthentication = false;
   };
 
+  # Automatically collect garbage from the Nix store.
+  services.depot.automatic-gc = {
+    enable = true;
+    interval = "1 hour";
+    diskThreshold = 200; # GiB
+    maxFreed = 420; # GiB
+    preserveGenerations = "90d";
+  };
+
   # Run a handful of Buildkite agents to support parallel builds.
   services.depot.buildkite = {
     enable = true;