From 93dcc3daa9aa42698823305a79e0957089af652d Mon Sep 17 00:00:00 2001 From: Scott Edlund Date: Sun, 17 Mar 2024 17:54:44 +0800 Subject: [PATCH] nix.gc: let systemd use any time config --- modules/services/nix-gc.nix | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/services/nix-gc.nix b/modules/services/nix-gc.nix index 6c837330e..8ac26dfee 100644 --- a/modules/services/nix-gc.nix +++ b/modules/services/nix-gc.nix @@ -4,6 +4,8 @@ with lib; let cfg = config.nix.gc; + darwinIntervals = + [ "hourly" "daily" "weekly" "monthly" "semiannually" "annually" ]; mkCalendarInterval = frequency: let @@ -66,21 +68,16 @@ in { }; frequency = mkOption { - type = types.enum [ - "hourly" - "daily" - "weekly" - "monthly" - "semiannually" - "annually" - ]; + type = types.str; default = "weekly"; - example = "monthly"; + example = "03:15"; description = '' - The frequency at which to run the garbage collector. + When to run the Nix garbage collector. - These enums are based on special expressions from the - {manpage}`systemd.time(7)` + On Linux this is a string as defined by {manpage}`systemd.time(7)`. + + On Darwin it must be one of: ${toString darwinIntervals}, which are + implemented as defined in the manual page above. ''; }; @@ -117,6 +114,13 @@ in { }) (mkIf pkgs.stdenv.isDarwin { + assertions = [{ + assertion = elem cfg.frequency darwinIntervals; + message = "On Darwin nix.gc.frequency must be one of: ${ + toString darwinIntervals + }."; + }]; + launchd.agents.nix-gc = { enable = true; config = {