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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.4 KiB
Nix
Raw Normal View History

2017-10-30 00:29:25 +00:00
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.tautulli;
2017-10-30 00:29:25 +00:00
in
{
imports = [
(mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
];
2017-10-30 00:29:25 +00:00
options = {
services.tautulli = {
enable = mkEnableOption (lib.mdDoc "Tautulli Plex Monitor");
2017-10-30 00:29:25 +00:00
dataDir = mkOption {
type = types.str;
default = "/var/lib/plexpy";
description = lib.mdDoc "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";
description = lib.mdDoc "The location of Tautulli's config file.";
2017-10-30 00:29:25 +00:00
};
port = mkOption {
type = types.int;
default = 8181;
description = lib.mdDoc "TCP port where Tautulli listens.";
2017-10-30 00:29:25 +00:00
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc "Open ports in the firewall for Tautulli.";
};
2017-10-30 00:29:25 +00:00
user = mkOption {
type = types.str;
default = "plexpy";
description = lib.mdDoc "User account under which Tautulli runs.";
2017-10-30 00:29:25 +00:00
};
group = mkOption {
type = types.str;
default = "nogroup";
description = lib.mdDoc "Group under which Tautulli runs.";
2017-10-30 00:29:25 +00:00
};
package = mkOption {
type = types.package;
default = pkgs.tautulli;
defaultText = literalExpression "pkgs.tautulli";
description = lib.mdDoc ''
The Tautulli package to use.
2017-10-30 00:29:25 +00: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 00:29:25 +00: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 00:29:25 +00:00
Restart = "on-failure";
};
};
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
users.users = mkIf (cfg.user == "plexpy") {
2017-10-30 00:29:25 +00:00
plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; };
};
};
}