1 { config, lib, pkgs, ... }:
7 cfg = config.services.tuptime;
11 options.services.tuptime = {
13 enable = mkEnableOption (lib.mdDoc "the total uptime service");
19 description = lib.mdDoc "Whether to regularly log uptime to detect bad shutdowns.";
25 description = lib.mdDoc "systemd calendar event";
31 config = mkIf cfg.enable {
33 environment.systemPackages = [ pkgs.tuptime ];
36 groups._tuptime.members = [ "_tuptime" ];
40 description = "tuptime database owner";
48 description = "The total uptime service";
49 documentation = [ "man:tuptime(1)" ];
50 after = [ "time-sync.target" ];
51 wantedBy = [ "multi-user.target" ];
53 StateDirectory = "tuptime";
56 RemainAfterExit = true;
57 ExecStart = "${pkgs.tuptime}/bin/tuptime -x";
58 ExecStop = "${pkgs.tuptime}/bin/tuptime -xg";
62 tuptime-sync = mkIf cfg.timer.enable {
63 description = "Tuptime scheduled sync service";
67 ExecStart = "${pkgs.tuptime}/bin/tuptime -x";
72 timers.tuptime-sync = mkIf cfg.timer.enable {
73 description = "Tuptime scheduled sync timer";
74 # this timer should be started if the service is started
75 # even if the timer was previously stopped
76 wantedBy = [ "tuptime.service" "timers.target" ];
77 # this timer should be stopped if the service is stopped
78 partOf = [ "tuptime.service" ];
81 OnCalendar = cfg.timer.period;
82 Unit = "tuptime-sync.service";
88 meta.maintainers = [ maintainers.evils ];