diff --git a/modules/launchd/launchd.nix b/modules/launchd/launchd.nix index b1a2d395b..63bb3c665 100644 --- a/modules/launchd/launchd.nix +++ b/modules/launchd/launchd.nix @@ -350,49 +350,52 @@ with lib; up. If multiple intervals transpire before the computer is woken, those events will be coalesced into one event upon wake from sleep. ''; - type = types.nullOr (types.listOf (types.submodule { - options = { - Minute = mkOption { - type = types.nullOr types.int; - default = null; - description = lib.mdDoc '' - The minute on which this job will be run. - ''; - }; - - Hour = mkOption { - type = types.nullOr types.int; - default = null; - description = lib.mdDoc '' - The hour on which this job will be run. - ''; - }; - - Day = mkOption { - type = types.nullOr types.int; - default = null; - description = lib.mdDoc '' - The day on which this job will be run. - ''; - }; - - Weekday = mkOption { - type = types.nullOr types.int; - default = null; - description = lib.mdDoc '' - The weekday on which this job will be run (0 and 7 are Sunday). - ''; - }; - - Month = mkOption { - type = types.nullOr types.int; - default = null; - description = lib.mdDoc '' - The month on which this job will be run. - ''; + type = let + submod = types.submodule { + options = { + Minute = mkOption { + type = types.nullOr (types.ints.between 0 59); + default = null; + description = lib.mdDoc '' + The minute on which this job will be run. + ''; + }; + + Hour = mkOption { + type = types.nullOr (types.ints.between 0 23); + default = null; + description = lib.mdDoc '' + The hour on which this job will be run. + ''; + }; + + Day = mkOption { + type = types.nullOr (types.ints.between 1 31); + default = null; + description = lib.mdDoc '' + The day on which this job will be run. + ''; + }; + + Weekday = mkOption { + type = types.nullOr (types.ints.between 0 7); + default = null; + description = lib.mdDoc '' + The weekday on which this job will be run (0 and 7 are Sunday). + ''; + }; + + Month = mkOption { + type = types.nullOr (types.ints.between 1 12); + default = null; + description = lib.mdDoc '' + The month on which this job will be run. + ''; + }; }; }; - })); + in + types.nullOr (types.either submod (types.addCheck (types.listOf submod) (x: x != []))); }; StandardInPath = mkOption { diff --git a/modules/services/nix-gc/default.nix b/modules/services/nix-gc/default.nix index f13e250cc..a703ed41a 100644 --- a/modules/services/nix-gc/default.nix +++ b/modules/services/nix-gc/default.nix @@ -6,6 +6,7 @@ with lib; let cfg = config.nix.gc; + launchdConfig = import ../../launchd/launchd.nix {inherit config lib;}; in { @@ -35,9 +36,12 @@ in }; interval = mkOption { - type = types.attrs; + type = let + t = launchdConfig.options.StartCalendarInterval.type; + in + types.addCheck (t // {description = lib.removePrefix "null or" t.description;}) (x: x != null); default = { Hour = 3; Minute = 15; }; - description = lib.mdDoc "The time interval at which the garbage collector will run."; + description = lib.mdDoc "The calendar interval at which the garbage collector will run."; }; options = mkOption { @@ -63,7 +67,7 @@ in command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}"; environment.NIX_REMOTE = optionalString config.nix.useDaemon "daemon"; serviceConfig.RunAtLoad = false; - serviceConfig.StartCalendarInterval = [ cfg.interval ]; + serviceConfig.StartCalendarInterval = cfg.interval; serviceConfig.UserName = cfg.user; };