mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 17:25:11 +00:00
83a9bf9a6a
(e.g., startOn = "started foo" instead of startOn = "foo"). svn path=/nixos/branches/upstart-0.6/; revision=18230
76 lines
1.3 KiB
Nix
76 lines
1.3 KiB
Nix
{pkgs, config, ...}:
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption mkIf singleton;
|
|
|
|
inherit (pkgs) uptimed;
|
|
|
|
stateDir = "/var/spool/uptimed";
|
|
|
|
uptimedUser = "uptimed";
|
|
|
|
modprobe = config.system.sbin.modprobe;
|
|
|
|
uptimedFlags = "";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.uptimed = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = ''
|
|
Uptimed allows you to track your highest uptimes.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.uptimed.enable {
|
|
|
|
environment.systemPackages = [ uptimed ];
|
|
|
|
users.extraUsers = singleton
|
|
{ name = uptimedUser;
|
|
uid = config.ids.uids.uptimed;
|
|
description = "Uptimed daemon user";
|
|
home = stateDir;
|
|
};
|
|
|
|
jobs.uptimed =
|
|
{ description = "Uptimed daemon";
|
|
|
|
startOn = "startup";
|
|
|
|
preStart =
|
|
''
|
|
mkdir -m 0755 -p ${stateDir}
|
|
chown ${uptimedUser} ${stateDir}
|
|
|
|
# Needed to run uptimed as an unprivileged user.
|
|
${modprobe}/sbin/modprobe capability || true
|
|
|
|
if ! test -f ${stateDir}/bootid ; then
|
|
${uptimed}/sbin/uptimed -b
|
|
fi
|
|
'';
|
|
|
|
exec = "${uptimed}/sbin/uptimed ${uptimedFlags}";
|
|
};
|
|
|
|
};
|
|
|
|
}
|