From c6b56d87ffac98f9af3c405c5375ae2ee35a62af Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Sat, 10 Jan 2026 14:37:44 +0100 Subject: [PATCH] gc: Enable on servers with gcroot cleanup only --- hosts/vps-monitor/default.nix | 5 +++++ hosts/vps-private/default.nix | 5 +++++ hosts/vps-public/default.nix | 5 +++++ modules/system/services/gc.nix | 18 +++++++++++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/hosts/vps-monitor/default.nix b/hosts/vps-monitor/default.nix index af385b3..0d751cd 100644 --- a/hosts/vps-monitor/default.nix +++ b/hosts/vps-monitor/default.nix @@ -21,6 +21,11 @@ boot.loader.grub.enable = true; services = { + gc = { + enable = true; + onlyCleanRoots = true; + }; + tailscale.enable = true; nebula.node = { diff --git a/hosts/vps-private/default.nix b/hosts/vps-private/default.nix index 547d9c1..c0065f2 100644 --- a/hosts/vps-private/default.nix +++ b/hosts/vps-private/default.nix @@ -25,6 +25,11 @@ boot.loader.systemd-boot.enable = true; services = { + gc = { + enable = true; + onlyCleanRoots = true; + }; + tailscale = { enable = true; exitNode.enable = true; diff --git a/hosts/vps-public/default.nix b/hosts/vps-public/default.nix index 1b5f0c3..a59538f 100644 --- a/hosts/vps-public/default.nix +++ b/hosts/vps-public/default.nix @@ -21,6 +21,11 @@ boot.loader.systemd-boot.enable = true; services = { + gc = { + enable = true; + onlyCleanRoots = true; + }; + tailscale.enable = true; nebula.node = { diff --git a/modules/system/services/gc.nix b/modules/system/services/gc.nix index 29b09ac..e162053 100644 --- a/modules/system/services/gc.nix +++ b/modules/system/services/gc.nix @@ -1,14 +1,26 @@ { config, lib, ... }: +let + cfg = config.custom.services.gc; +in { - options.custom.services.gc.enable = lib.mkEnableOption ""; + options.custom.services.gc = { + enable = lib.mkEnableOption ""; + onlyCleanRoots = lib.mkEnableOption ""; + }; - config = lib.mkIf config.custom.services.gc.enable { + config = lib.mkIf cfg.enable { programs.nh = { enable = true; clean = { enable = true; dates = "weekly"; - extraArgs = "--keep 10 --keep-since 7d"; + extraArgs = + [ + "--keep 10" + "--keep-since 7d" + (lib.optionalString cfg.onlyCleanRoots "--no-gc") + ] + |> lib.concatStringsSep " "; }; }; };