···159 which the prune will occur.
160 '';
161 };
162+163+ randomizedDelaySec = mkOption {
164+ default = "0";
165+ type = types.singleLineStr;
166+ example = "45min";
167+ description = ''
168+ Add a randomized delay before each auto prune.
169+ The delay will be chosen between zero and this value.
170+ This value must be a time span in the format specified by
171+ {manpage}`systemd.time(7)`
172+ '';
173+ };
174+175+ persistent = mkOption {
176+ default = true;
177+ type = types.bool;
178+ example = false;
179+ description = ''
180+ Takes a boolean argument. If true, the time when the service
181+ unit was last triggered is stored on disk. When the timer is
182+ activated, the service unit is triggered immediately if it
183+ would have been triggered at least once during the time when
184+ the timer was inactive. Such triggering is nonetheless
185+ subject to the delay imposed by RandomizedDelaySec=. This is
186+ useful to catch up on missed runs of the service when the
187+ system was powered down.
188+ '';
189+ };
190 };
191192 package = mkPackageOption pkgs "docker" { };
···280 startAt = optional cfg.autoPrune.enable cfg.autoPrune.dates;
281 after = [ "docker.service" ];
282 requires = [ "docker.service" ];
283+ };
284+285+ systemd.timers.docker-prune = mkIf cfg.autoPrune.enable {
286+ timerConfig = {
287+ RandomizedDelaySec = cfg.autoPrune.randomizedDelaySec;
288+ Persistent = cfg.autoPrune.persistent;
289+ };
290 };
291292 assertions = [