From 102ae0ee62fb52bbc60a905635774a8a959077b3 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sun, 8 Oct 2023 21:09:25 +0200 Subject: [PATCH] feat: automatic garbage collection --- README.md | 4 +++- modules/base.nix | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3afd118..8a55cff 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,9 @@ systemctl --failed * https://nixos.org/manual/nix/stable/package-management/garbage-collection.html * https://discourse.nixos.org/t/why-doesnt-nix-collect-garbage-remove-old-generations-from-efi-menu/17592/4 -For all profiles: +This is automated in [base.nix](modules/base.nix) with the `nix.gc` option. + +Run manually for all profiles: ```shell sudo nix-collect-garbage --delete-older-than 14d diff --git a/modules/base.nix b/modules/base.nix index 1b3babc..11b5aac 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -121,6 +121,13 @@ nix.settings.auto-optimise-store = true; + # https://nixos.wiki/wiki/Storage_optimization#Automation + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + # Firewall. # https://nixos.wiki/wiki/Firewall # -> Firewall rules may be overwritten by docker, as per https://github.com/NixOS/nixpkgs/issues/111852