nix.gc: let systemd use any time config
This commit is contained in:
parent
baf7659448
commit
93dcc3daa9
|
@ -4,6 +4,8 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.nix.gc;
|
cfg = config.nix.gc;
|
||||||
|
darwinIntervals =
|
||||||
|
[ "hourly" "daily" "weekly" "monthly" "semiannually" "annually" ];
|
||||||
|
|
||||||
mkCalendarInterval = frequency:
|
mkCalendarInterval = frequency:
|
||||||
let
|
let
|
||||||
|
@ -66,21 +68,16 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
frequency = mkOption {
|
frequency = mkOption {
|
||||||
type = types.enum [
|
type = types.str;
|
||||||
"hourly"
|
|
||||||
"daily"
|
|
||||||
"weekly"
|
|
||||||
"monthly"
|
|
||||||
"semiannually"
|
|
||||||
"annually"
|
|
||||||
];
|
|
||||||
default = "weekly";
|
default = "weekly";
|
||||||
example = "monthly";
|
example = "03:15";
|
||||||
description = ''
|
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
|
On Linux this is a string as defined by {manpage}`systemd.time(7)`.
|
||||||
{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 {
|
(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 = {
|
launchd.agents.nix-gc = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = {
|
config = {
|
||||||
|
|
Loading…
Reference in a new issue