1 { config, pkgs, lib, ... }:
3 cfg = config.services.tautulli;
7 (lib.mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
12 enable = lib.mkEnableOption "Tautulli Plex Monitor";
14 dataDir = lib.mkOption {
16 default = "/var/lib/plexpy";
17 description = "The directory where Tautulli stores its data files.";
20 configFile = lib.mkOption {
22 default = "/var/lib/plexpy/config.ini";
23 description = "The location of Tautulli's config file.";
27 type = lib.types.port;
29 description = "TCP port where Tautulli listens.";
32 openFirewall = lib.mkOption {
33 type = lib.types.bool;
35 description = "Open ports in the firewall for Tautulli.";
41 description = "User account under which Tautulli runs.";
44 group = lib.mkOption {
47 description = "Group under which Tautulli runs.";
50 package = lib.mkPackageOption pkgs "tautulli" { };
54 config = lib.mkIf cfg.enable {
55 systemd.tmpfiles.rules = [
56 "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
59 systemd.services.tautulli = {
60 description = "Tautulli Plex Monitor";
61 after = [ "network.target" ];
62 wantedBy = [ "multi-user.target" ];
67 GuessMainPID = "false";
68 ExecStart = "${cfg.package}/bin/tautulli --datadir ${cfg.dataDir} --config ${cfg.configFile} --port ${toString cfg.port} --pidfile ${cfg.dataDir}/tautulli.pid --nolaunch";
69 Restart = "on-failure";
73 networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
75 users.users = lib.mkIf (cfg.user == "plexpy") {
76 plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; };