2014-05-05 19:58:51 +01:00
|
|
|
{pkgs, config, lib, ...}:
|
2009-09-16 08:48:47 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
inherit (lib) mkOption mkIf singleton;
|
2009-09-16 08:48:47 +01:00
|
|
|
|
|
|
|
inherit (pkgs) uptimed;
|
|
|
|
|
|
|
|
stateDir = "/var/spool/uptimed";
|
|
|
|
|
|
|
|
uptimedUser = "uptimed";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 08:48:47 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 08:48:47 +01:00
|
|
|
services.uptimed = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2009-09-16 08:49:23 +01:00
|
|
|
default = false;
|
2009-09-16 08:48:47 +01:00
|
|
|
description = ''
|
|
|
|
Uptimed allows you to track your highest uptimes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.uptimed.enable {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 09:01:03 +01:00
|
|
|
environment.systemPackages = [ uptimed ];
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 08:48:47 +01:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = uptimedUser;
|
|
|
|
uid = config.ids.uids.uptimed;
|
|
|
|
description = "Uptimed daemon user";
|
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2009-10-12 19:09:34 +01:00
|
|
|
jobs.uptimed =
|
2009-10-12 18:09:38 +01:00
|
|
|
{ description = "Uptimed daemon";
|
2009-09-16 08:48:47 +01:00
|
|
|
|
2009-10-12 18:09:38 +01:00
|
|
|
startOn = "startup";
|
2009-09-16 08:48:47 +01:00
|
|
|
|
2009-10-12 18:09:38 +01:00
|
|
|
preStart =
|
|
|
|
''
|
2009-09-16 08:48:47 +01:00
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${uptimedUser} ${stateDir}
|
|
|
|
|
|
|
|
if ! test -f ${stateDir}/bootid ; then
|
|
|
|
${uptimed}/sbin/uptimed -b
|
|
|
|
fi
|
2009-10-12 18:09:38 +01:00
|
|
|
'';
|
2009-09-16 08:48:47 +01:00
|
|
|
|
2012-03-17 17:26:17 +00:00
|
|
|
exec = "${uptimed}/sbin/uptimed";
|
2009-10-12 18:09:38 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 08:48:47 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 08:48:47 +01:00
|
|
|
}
|