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