@cryptotaxi247 / infra / commits / e03f7977

macs: percentage based garbage collection

Given that we now have various sizes of macs a percentage based gc is much more appropriate and fits better with how we monitor these machines.

Martin Weinelt committed Jan 7, 2025 at 01:22 UTC e03f79770fcc0365e504a0f5b56c6e9a341e8d59
1 file changed +3 -5
macs/nix-darwin.nix
+3 -5
@@ -63,13 +63,11 @@ in
63 automatic = true;
64 user = "root";
65 interval = {
66 + # hourly at the 15th minute
67 Minute = 15;
68 };
68 - options =
69 - let
70 - gbFree = 100;
71 - in
72 - "--max-freed $((${toString gbFree} * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | awk '{ print $4 }')))";
69 + # free up to 15% of total capacity
70 + options = "--max-freed $(df -P -k /nix/store | awk 'NR==2 {total=$2; available=$4; required=total*0.15; to_free=required-available; printf \"%.0d\", to_free*1024}')";
71 };
72 };
73