2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.tautulli;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.tautulli = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Tautulli Plex Monitor");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/plexpy";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The directory where Tautulli stores its data files.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
configFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/plexpy/config.ini";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The location of Tautulli's config file.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2022-11-21 17:40:18 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 8181;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "TCP port where Tautulli listens.";
|
|
|
|
};
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = lib.mdDoc "Open ports in the firewall for Tautulli.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "plexpy";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "User account under which Tautulli runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "nogroup";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Group under which Tautulli runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "tautulli" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.services.tautulli = {
|
|
|
|
description = "Tautulli Plex Monitor";
|
|
|
|
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";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
users.users = mkIf (cfg.user == "plexpy") {
|
|
|
|
plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|