From af3224a1d589aef9ca326202d8ca6c4ee5a3882a Mon Sep 17 00:00:00 2001 From: Swarsel Date: Thu, 11 Jul 2024 11:08:22 +0200 Subject: [PATCH] feat: add NixOS auto-GC and -store optimisation --- SwarselSystems.org | 27 +++++++++++++++++++++++++++ profiles/common/nixos.nix | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/SwarselSystems.org b/SwarselSystems.org index 8962572..2b84fb1 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -4660,6 +4660,33 @@ Needed for control over system-wide privileges etc. #+end_src +**** Enable automatic garbage collection + +The nix store fills up over time, until =/boot/efi= is filled. This snippet cleans it automatically on a weekly basis. + +#+begin_src nix :tangle profiles/common/nixos.nix + + nix.gc = { + automatic = true; + randomizedDelaySec = "14m"; + dates = "weekly"; + options = "--delete-older-than 10d"; + }; + +#+end_src + +**** Enable automatic store optimisation + +This enables hardlinking identical files in the nix store, to save on disk space. I have read this incurs a significant I/O overhead, I need to keep an eye on this. + +#+begin_src nix :tangle profiles/common/nixos.nix + + nix.optimise = { + automatic = true; + dates = [ "weekly" ]; + }; + +#+end_src **** Reduce systemd timeouts :PROPERTIES: diff --git a/profiles/common/nixos.nix b/profiles/common/nixos.nix index 830730f..1e1042b 100644 --- a/profiles/common/nixos.nix +++ b/profiles/common/nixos.nix @@ -32,6 +32,18 @@ stylix.targets.grub.enable = false; # the styling makes grub more ugly security.polkit.enable = true; +nix.gc = { + automatic = true; + randomizedDelaySec = "14m"; + dates = "weekly"; + options = "--delete-older-than 10d"; +}; + +nix.optimise = { + automatic = true; + dates = [ "weekly" ]; +}; + # systemd systemd.extraConfig = '' DefaultTimeoutStartSec=60s