mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
services.nix-gc: extract darwin agent interval code to new library file
This commit is contained in:
parent
3b930bb653
commit
1c2fccef83
3 changed files with 80 additions and 66 deletions
76
modules/lib/darwin.nix
Normal file
76
modules/lib/darwin.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{ lib }:
|
||||
let
|
||||
intervals = [
|
||||
"hourly"
|
||||
"daily"
|
||||
"weekly"
|
||||
"monthly"
|
||||
"semiannually"
|
||||
"annually"
|
||||
];
|
||||
|
||||
mkCalendarInterval =
|
||||
frequency:
|
||||
let
|
||||
freq = {
|
||||
"hourly" = [ { Minute = 0; } ];
|
||||
"daily" = [
|
||||
{
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
];
|
||||
"weekly" = [
|
||||
{
|
||||
Weekday = 1;
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
];
|
||||
"monthly" = [
|
||||
{
|
||||
Day = 1;
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
];
|
||||
"semiannually" = [
|
||||
{
|
||||
Month = 1;
|
||||
Day = 1;
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
{
|
||||
Month = 7;
|
||||
Day = 1;
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
];
|
||||
"annually" = [
|
||||
{
|
||||
Month = 1;
|
||||
Day = 1;
|
||||
Hour = 0;
|
||||
Minute = 0;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
freq.${frequency} or null;
|
||||
|
||||
intervalsString = lib.concatStringsSep ", " intervals;
|
||||
|
||||
assertInterval = option: interval: pkgs: {
|
||||
assertion = (!pkgs.stdenv.isDarwin) || (lib.elem interval intervals);
|
||||
message = "On Darwin ${option} must be one of: ${intervalsString}.";
|
||||
};
|
||||
|
||||
intervalDocumentation = ''
|
||||
On Darwin it must be one of: ${intervalsString}, which are implemented as defined in {manpage}`systemd.time(7)`.
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit mkCalendarInterval assertInterval intervalDocumentation;
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ rec {
|
|||
assertions = import ./assertions.nix { inherit lib; };
|
||||
|
||||
booleans = import ./booleans.nix { inherit lib; };
|
||||
darwin = import ./darwin.nix { inherit lib; };
|
||||
deprecations = import ./deprecations.nix { inherit lib; };
|
||||
generators = import ./generators.nix { inherit lib; };
|
||||
gvariant = import ./gvariant.nix { inherit lib; };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue