From e6a7f3f4411da8b3ed47dde80f01be7304d7c88e Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sun, 17 May 2026 09:02:19 +0000 Subject: [PATCH] Specify times for nix-gc and optimise (assume UTC) --- modules/nix-gc.nix | 15 +++++++++++++-- modules/nix-settings.nix | 22 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/nix-gc.nix b/modules/nix-gc.nix index 2397107..c0264ce 100644 --- a/modules/nix-gc.nix +++ b/modules/nix-gc.nix @@ -1,7 +1,18 @@ -_: { +{ lib, options, ... }: +{ nix.gc = { automatic = true; - dates = "weekly"; options = "--delete-older-than 60d"; + } + // lib.optionalAttrs (options.nix.gc ? dates) { + # NixOS + dates = lib.mkDefault "00:15"; + } + // lib.optionalAttrs (options.nix.gc ? interval) { + # Darwin + interval = lib.mkDefault { + Hour = 0; + Minute = 15; + }; }; } diff --git a/modules/nix-settings.nix b/modules/nix-settings.nix index 5d43615..28a9fc2 100644 --- a/modules/nix-settings.nix +++ b/modules/nix-settings.nix @@ -1,4 +1,5 @@ -_: { +{ lib, options, ... }: +{ nix.settings = { extra-experimental-features = [ "nix-command" @@ -11,7 +12,20 @@ _: { download-buffer-size = 1 * 1024 * 1024 * 1024; }; - # Instead of nix.settings.auto-optimise-store, which adds overhead to each - # build. - nix.optimise.automatic = true; + nix.optimise = { + # Instead of nix.settings.auto-optimise-store, which adds overhead to each + # build. + automatic = true; + } + // lib.optionalAttrs (options.nix.optimise ? dates) { + # NixOS + dates = lib.mkDefault "00:45"; + } + // lib.optionalAttrs (options.nix.optimise ? interval) { + # Darwin + interval = lib.mkDefault { + Hour = 0; + Minute = 45; + }; + }; }