From 54347214702f7fc439fe2577d5048a64debcea31 Mon Sep 17 00:00:00 2001 From: Henri Rosten Date: Tue, 27 Feb 2024 10:25:03 +0200 Subject: [PATCH] azure-common: Initial garbage-collection config Signed-off-by: Henri Rosten --- hosts/azure-common.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hosts/azure-common.nix b/hosts/azure-common.nix index 968bbd91..f228f6f3 100644 --- a/hosts/azure-common.nix +++ b/hosts/azure-common.nix @@ -7,7 +7,9 @@ modulesPath, pkgs, ... -}: { +}: let + asGB = size: toString (size * 1024 * 1024 * 1024); +in { imports = [ "${modulesPath}/virtualisation/azure-config.nix" ]; @@ -16,7 +18,20 @@ settings = { # Enable flakes and 'nix' command experimental-features = "nix-command flakes"; + # When free disk space in /nix/store drops below min-free during build, + # perform a garbage-collection until max-free bytes are available or there + # is no more garbage. + min-free = asGB 10; + max-free = asGB 50; + # check the free disk space every 5 seconds + min-free-check-interval = 5; }; + # Garbage collection + gc.automatic = true; + gc.options = pkgs.lib.mkDefault "--delete-older-than 7d"; + }; + systemd.services.nix-gc.serviceConfig = { + Restart = "on-failure"; }; # Enable azure agent