2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.uptimed;
|
2021-08-05 21:33:18 +00:00
|
|
|
stateDir = "/var/lib/uptimed";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.uptimed = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Enable `uptimed`, allowing you to track
|
2020-04-24 23:36:52 +00:00
|
|
|
your highest uptimes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-08-05 21:33:18 +00:00
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.uptimed ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
users.users.uptimed = {
|
|
|
|
description = "Uptimed daemon user";
|
|
|
|
home = stateDir;
|
|
|
|
uid = config.ids.uids.uptimed;
|
2021-08-05 21:33:18 +00:00
|
|
|
group = "uptimed";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-08-05 21:33:18 +00:00
|
|
|
users.groups.uptimed = {};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.services.uptimed = {
|
|
|
|
unitConfig.Documentation = "man:uptimed(8) man:uprecords(1)";
|
|
|
|
description = "uptimed service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "on-failure";
|
|
|
|
User = "uptimed";
|
|
|
|
Nice = 19;
|
|
|
|
IOSchedulingClass = "idle";
|
|
|
|
PrivateTmp = "yes";
|
|
|
|
PrivateNetwork = "yes";
|
|
|
|
NoNewPrivileges = "yes";
|
2021-08-05 21:33:18 +00:00
|
|
|
StateDirectory = [ "uptimed" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
InaccessibleDirectories = "/home";
|
|
|
|
ExecStart = "${pkgs.uptimed}/sbin/uptimed -f -p ${stateDir}/pid";
|
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
if ! test -f ${stateDir}/bootid ; then
|
|
|
|
${pkgs.uptimed}/sbin/uptimed -b
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|