nixpkgs/nixos/modules/services/misc/tautulli.nix

78 lines
1.9 KiB
Nix
Raw Normal View History

2017-10-30 01:29:25 +01:00
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.tautulli;
2017-10-30 01:29:25 +01:00
in
{
options = {
services.tautulli = {
enable = mkEnableOption "Tautulli Plex Monitor";
2017-10-30 01:29:25 +01:00
dataDir = mkOption {
type = types.str;
default = "/var/lib/plexpy";
description = "The directory where Tautulli stores its data files.";
2017-10-30 01:29:25 +01:00
};
configFile = mkOption {
type = types.str;
default = "/var/lib/plexpy/config.ini";
description = "The location of Tautulli's config file.";
2017-10-30 01:29:25 +01:00
};
port = mkOption {
type = types.int;
default = 8181;
description = "TCP port where Tautulli listens.";
2017-10-30 01:29:25 +01:00
};
user = mkOption {
type = types.str;
default = "plexpy";
description = "User account under which Tautulli runs.";
2017-10-30 01:29:25 +01:00
};
group = mkOption {
type = types.str;
default = "nogroup";
description = "Group under which Tautulli runs.";
2017-10-30 01:29:25 +01:00
};
package = mkOption {
type = types.package;
default = pkgs.tautulli;
defaultText = "pkgs.tautulli";
2017-10-30 01:29:25 +01:00
description = ''
The Tautulli package to use.
2017-10-30 01:29:25 +01:00
'';
};
};
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
];
systemd.services.tautulli = {
description = "Tautulli Plex Monitor";
2017-10-30 01:29:25 +01:00
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
GuessMainPID = "false";
ExecStart = "${cfg.package}/bin/tautulli --datadir ${cfg.dataDir} --config ${cfg.configFile} --port ${toString cfg.port} --pidfile ${cfg.dataDir}/tautulli.pid --nolaunch";
2017-10-30 01:29:25 +01:00
Restart = "on-failure";
};
};
users.users = mkIf (cfg.user == "plexpy") {
2017-10-30 01:29:25 +01:00
plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; };
};
};
}