1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 11:40:45 +00:00
nixpkgs/nixos/modules/services/system/uptimed.nix
Dan Peebles 7ccda42007 nixos: uptimed - rewrite and harden a bit (#7220)
This is mostly @thoughtpolice's work, but I cleaned it up a bit.
2016-01-23 19:28:01 +00:00

56 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.uptimed;
stateDir = "/var/spool/uptimed";
in
{
options = {
services.uptimed = {
enable = mkOption {
default = false;
description = ''
Enable <literal>uptimed</literal>, allowing you to track
your highest uptimes.
'';
};
};
};
config = mkIf cfg.enable {
users.extraUsers.uptimed = {
description = "Uptimed daemon user";
home = stateDir;
createHome = true;
uid = config.ids.uids.uptimed;
};
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";
ReadWriteDirectories = stateDir;
InaccessibleDirectories = "/home";
ExecStart = "${pkgs.uptimed}/sbin/uptimed -f -p ${stateDir}/pid";
};
preStart = ''
if ! test -f ${stateDir}/bootid ; then
${pkgs.uptimed}/sbin/uptimed -b
fi
'';
};
};
}