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