aerospike: 7.2.0.4 -> 7.2.0.6 (#373809)
[NixPkgs.git] / nixos / modules / services / system / uptimed.nix
blobfaa949c3089b1929da6ad15010f46cb01e85ff60
2   config,
3   lib,
4   pkgs,
5   ...
6 }:
7 let
8   cfg = config.services.uptimed;
9   stateDir = "/var/lib/uptimed";
12   options = {
13     services.uptimed = {
14       enable = lib.mkOption {
15         type = lib.types.bool;
16         default = false;
17         description = ''
18           Enable `uptimed`, allowing you to track
19           your highest uptimes.
20         '';
21       };
22     };
23   };
25   config = lib.mkIf cfg.enable {
27     environment.systemPackages = [ pkgs.uptimed ];
29     users.users.uptimed = {
30       description = "Uptimed daemon user";
31       home = stateDir;
32       uid = config.ids.uids.uptimed;
33       group = "uptimed";
34     };
35     users.groups.uptimed = { };
37     systemd.services.uptimed = {
38       unitConfig.Documentation = "man:uptimed(8) man:uprecords(1)";
39       description = "uptimed service";
40       wantedBy = [ "multi-user.target" ];
42       serviceConfig = {
43         Restart = "on-failure";
44         User = "uptimed";
45         Nice = 19;
46         IOSchedulingClass = "idle";
47         PrivateTmp = "yes";
48         PrivateNetwork = "yes";
49         NoNewPrivileges = "yes";
50         StateDirectory = [ "uptimed" ];
51         InaccessibleDirectories = "/home";
52         ExecStart = "${pkgs.uptimed}/sbin/uptimed -f -p ${stateDir}/pid";
53       };
55       preStart = ''
56         if ! test -f ${stateDir}/bootid ; then
57           ${pkgs.uptimed}/sbin/uptimed -b
58         fi
59       '';
60     };
61   };