From 83bfe1bac8e0d930f36cee6874bd17e77c8754d1 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Tue, 4 Jun 2024 06:20:47 +0200 Subject: [PATCH] nix-gc: add `persistent` option (#5490) Mirrors the `nix.gc.persistent` option in nixpkgs: https://search.nixos.org/options?channel=unstable&show=nix.gc.persistent&from=0&size=50&sort=relevance&type=packages&query=nix.gc.persistent --- modules/services/nix-gc.nix | 13 +++++++++++++ tests/modules/services/nix-gc/expected.timer | 1 + 2 files changed, 14 insertions(+) diff --git a/modules/services/nix-gc.nix b/modules/services/nix-gc.nix index 8ac26dfe..652c575a 100644 --- a/modules/services/nix-gc.nix +++ b/modules/services/nix-gc.nix @@ -90,6 +90,18 @@ in { garbage collector is run automatically. ''; }; + + persistent = mkOption { + type = types.bool; + default = true; + example = false; + description = '' + If true, the time when the service unit was last triggered is + stored on disk. When the timer is activated, the service unit is + triggered immediately if it would have been triggered at least once + during the time when the timer was inactive. + ''; + }; }; }; @@ -107,6 +119,7 @@ in { Unit = { Description = "Nix Garbage Collector"; }; Timer = { OnCalendar = "${cfg.frequency}"; + Persistent = cfg.persistent; Unit = "nix-gc.service"; }; Install = { WantedBy = [ "timers.target" ]; }; diff --git a/tests/modules/services/nix-gc/expected.timer b/tests/modules/services/nix-gc/expected.timer index 2b0c6603..ef30df43 100644 --- a/tests/modules/services/nix-gc/expected.timer +++ b/tests/modules/services/nix-gc/expected.timer @@ -3,6 +3,7 @@ WantedBy=timers.target [Timer] OnCalendar=monthly +Persistent=true Unit=nix-gc.service [Unit]