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
This commit is contained in:
Dawid Dziurla 2024-06-04 06:20:47 +02:00 committed by GitHub
parent 9b53a10f4c
commit 83bfe1bac8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -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" ]; };

View file

@ -3,6 +3,7 @@ WantedBy=timers.target
[Timer]
OnCalendar=monthly
Persistent=true
Unit=nix-gc.service
[Unit]