1 { config, pkgs, lib, ... }:
6 cfg = config.services.tautulli;
10 (mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
15 enable = mkEnableOption (lib.mdDoc "Tautulli Plex Monitor");
19 default = "/var/lib/plexpy";
20 description = lib.mdDoc "The directory where Tautulli stores its data files.";
23 configFile = mkOption {
25 default = "/var/lib/plexpy/config.ini";
26 description = lib.mdDoc "The location of Tautulli's config file.";
32 description = lib.mdDoc "TCP port where Tautulli listens.";
35 openFirewall = mkOption {
38 description = lib.mdDoc "Open ports in the firewall for Tautulli.";
44 description = lib.mdDoc "User account under which Tautulli runs.";
50 description = lib.mdDoc "Group under which Tautulli runs.";
55 default = pkgs.tautulli;
56 defaultText = literalExpression "pkgs.tautulli";
57 description = lib.mdDoc ''
58 The Tautulli package to use.
64 config = mkIf cfg.enable {
65 systemd.tmpfiles.rules = [
66 "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
69 systemd.services.tautulli = {
70 description = "Tautulli Plex Monitor";
71 after = [ "network.target" ];
72 wantedBy = [ "multi-user.target" ];
77 GuessMainPID = "false";
78 ExecStart = "${cfg.package}/bin/tautulli --datadir ${cfg.dataDir} --config ${cfg.configFile} --port ${toString cfg.port} --pidfile ${cfg.dataDir}/tautulli.pid --nolaunch";
79 Restart = "on-failure";
83 networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
85 users.users = mkIf (cfg.user == "plexpy") {
86 plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; };