diff --git a/modules/programs/venus.nix b/modules/programs/venus.nix
index c316163c8c7..2b3bfbc6c18 100644
--- a/modules/programs/venus.nix
+++ b/modules/programs/venus.nix
@@ -167,11 +167,7 @@ in
serviceConfig.User = "${cfg.user}";
serviceConfig.Group = "${cfg.group}";
environment.OPENSSL_X509_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";
- };
-
- systemd.timers.venus =
- { wantedBy = [ "timers.target" ];
- timerConfig.OnCalendar = cfg.dates;
+ startOn = cfg.dates;
};
};
diff --git a/modules/services/misc/nix-gc.nix b/modules/services/misc/nix-gc.nix
index dfc4fd3c2ff..dfdc4db65d5 100644
--- a/modules/services/misc/nix-gc.nix
+++ b/modules/services/misc/nix-gc.nix
@@ -48,22 +48,14 @@ in
###### implementation
- config = mkMerge [
+ config = {
- { systemd.services.nix-gc =
- { description = "Nix Garbage Collector";
- path = [ config.environment.nix ];
- script = "exec nix-collect-garbage ${cfg.options}";
- };
- }
+ systemd.services.nix-gc =
+ { description = "Nix Garbage Collector";
+ serviceConfig.ExecStart = "${config.environment.nix}/bin/nix-collect-garbage ${cfg.options}";
+ startAt = optionalString cfg.automatic cfg.dates;
+ };
- (mkIf cfg.automatic {
- systemd.timers.nix-gc =
- { wantedBy = [ "timers.target" ];
- timerConfig.OnCalendar = cfg.dates;
- };
- })
-
- ];
+ };
}
diff --git a/modules/system/boot/systemd-unit-options.nix b/modules/system/boot/systemd-unit-options.nix
index e6e8d9eb3b0..dfb9036ab4d 100644
--- a/modules/system/boot/systemd-unit-options.nix
+++ b/modules/system/boot/systemd-unit-options.nix
@@ -229,6 +229,20 @@ rec {
'';
};
+ startAt = mkOption {
+ type = types.uniq types.string;
+ default = "";
+ example = "Sun 14:00:00";
+ description = ''
+ Automatically start this unit at the given date/time, which
+ must be in the format described in
+ systemd.time
+ 5. This is equivalent
+ to adding a corresponding timer unit with
+ set to the value given here.
+ '';
+ };
+
};
diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix
index 35ae6a84024..a5e1165574c 100644
--- a/modules/system/boot/systemd.nix
+++ b/modules/system/boot/systemd.nix
@@ -628,6 +628,14 @@ in
users.extraGroups.systemd-journal.gid = config.ids.gids.systemd-journal;
+ # Generate timer units for all services that have a ‘startAt’ value.
+ systemd.timers =
+ mapAttrs (name: service:
+ { wantedBy = [ "timers.target" ];
+ timerConfig.OnCalendar = service.startAt;
+ })
+ (filterAttrs (name: service: service.startAt != "") cfg.services);
+
# FIXME: These are borrowed from upstream systemd.
systemd.services."systemd-update-utmp" =
{ description = "Update UTMP about System Reboot/Shutdown";