@cryptotaxi247 / infra / commits / 25aea778

builders: prune stale build roots hourly

In this we define stale build roots as those that have last been modified at least one day ago.

Martin Weinelt committed Feb 21, 2025 at 16:17 UTC 25aea778e1703f889a15692edf37df09c6c74928
1 file changed +18
builders/common/nix.nix
+18
@@ -1,5 +1,6 @@
1 {
2 config,
3 + lib,
4 pkgs,
5 ...
6 }:
@@ -42,4 +43,21 @@
43 max-silent-time = 7200; # 2h
44 };
45 };
46 +
47 + systemd.services.prune-stale-nix-builds = {
48 + description = "Prune stale nix build roots";
49 + startAt = "hourly";
50 + unitConfig.Documentation = "https://github.com/NixOS/nix/issues/5207";
51 + serviceConfig = {
52 + ExecStart = lib.concatStringsSep " " [
53 + (lib.getExe pkgs.findutils)
54 + "/tmp"
55 + "-maxdepth 1"
56 + "-type d"
57 + "-iname \"nix-build-*\""
58 + "-mtime +1" # days
59 + "-exec rm -rf {} +"
60 + ];
61 + };
62 + };
63 }