1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

nix-gc: add randomizedDelaySec option

There's no launchd equivalent to this option, so this is a no-op on
Darwin.
This commit is contained in:
Bruno BELANYI 2024-10-21 10:29:57 +00:00 committed by Robert Helgesson
parent c77c3bb233
commit 6cc03e337a
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
3 changed files with 15 additions and 0 deletions

View file

@ -81,6 +81,18 @@ in {
'';
};
randomizedDelaySec = lib.mkOption {
default = "0";
type = lib.types.singleLineStr;
example = "45min";
description = ''
Add a randomized delay before each garbage collection.
The delay will be chosen between zero and this value.
This value must be a time span in the format specified by
{manpage}`systemd.time(7)`
'';
};
options = mkOption {
type = types.nullOr types.str;
default = null;
@ -121,6 +133,7 @@ in {
Unit = { Description = "Nix Garbage Collector"; };
Timer = {
OnCalendar = "${cfg.frequency}";
RandomizedDelaySec = cfg.randomizedDelaySec;
Persistent = cfg.persistent;
Unit = "nix-gc.service";
};

View file

@ -4,6 +4,7 @@
nix.gc = {
automatic = true;
frequency = "monthly";
randomizedDelaySec = "42min";
options = "--delete-older-than 30d --max-freed $((64 * 1024**3))";
};

View file

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