From e1bef478ffb2d8124e513c50d5ca5eb7a583000e Mon Sep 17 00:00:00 2001 From: Mark Nipper Date: Thu, 4 Dec 2025 01:20:38 -0800 Subject: Add system wide and per user nix store garbage collection --- hosts/common/core/nix.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'hosts') diff --git a/hosts/common/core/nix.nix b/hosts/common/core/nix.nix index 3c798ae..3aac7fc 100644 --- a/hosts/common/core/nix.nix +++ b/hosts/common/core/nix.nix @@ -1,6 +1,12 @@ { inputs, lib, ... }: { nix = { + gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 7d"; + randomizedDelaySec = "5min"; + }; settings = { auto-optimise-store = lib.mkDefault true; experimental-features = [ "nix-command" "flakes" ]; @@ -8,4 +14,10 @@ warn-dirty = false; }; }; + + systemd.user.services."nix-gc" = { + description = "Garbage collection for user profiles"; + script = "/run/current-system/sw/bin/nix-collect-garbage --delete-older-than 7d"; + startAt = "daily"; + }; } -- cgit v1.2.3