1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-21 00:49:27 +03:00
nixpkgs/nixos/modules/services/misc/tautulli.nix

88 lines
2.2 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}:
2017-10-29 19:29:25 -05:00
let
cfg = config.services.tautulli;
2017-10-29 19:29:25 -05:00
in
{
imports = [
(lib.mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
];
2017-10-29 19:29:25 -05:00
options = {
services.tautulli = {
enable = lib.mkEnableOption "Tautulli Plex Monitor";
2017-10-29 19:29:25 -05:00
dataDir = lib.mkOption {
type = lib.types.str;
2017-10-29 19:29:25 -05:00
default = "/var/lib/plexpy";
description = "The directory where Tautulli stores its data files.";
2017-10-29 19:29:25 -05:00
};
configFile = lib.mkOption {
type = lib.types.str;
2017-10-29 19:29:25 -05:00
default = "/var/lib/plexpy/config.ini";
description = "The location of Tautulli's config file.";
2017-10-29 19:29:25 -05:00
};
port = lib.mkOption {
type = lib.types.port;
2017-10-29 19:29:25 -05:00
default = 8181;
description = "TCP port where Tautulli listens.";
2017-10-29 19:29:25 -05:00
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open ports in the firewall for Tautulli.";
};
user = lib.mkOption {
type = lib.types.str;
2017-10-29 19:29:25 -05:00
default = "plexpy";
description = "User account under which Tautulli runs.";
2017-10-29 19:29:25 -05:00
};
group = lib.mkOption {
type = lib.types.str;
2017-10-29 19:29:25 -05:00
default = "nogroup";
description = "Group under which Tautulli runs.";
2017-10-29 19:29:25 -05:00
};
package = lib.mkPackageOption pkgs "tautulli" { };
2017-10-29 19:29:25 -05:00
};
};
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
];
systemd.services.tautulli = {
description = "Tautulli Plex Monitor";
2017-10-29 19:29:25 -05: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-29 19:29:25 -05:00
Restart = "on-failure";
};
};
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
users.users = lib.mkIf (cfg.user == "plexpy") {
plexpy = {
group = cfg.group;
uid = config.ids.uids.plexpy;
};
2017-10-29 19:29:25 -05:00
};
};
}