diff options
author | Christopher Singley <csingley@gmail.com> | 2017-10-29 19:29:25 -0500 |
---|---|---|
committer | Christopher Singley <csingley@gmail.com> | 2017-10-29 19:29:25 -0500 |
commit | 95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b (patch) | |
tree | 35f4251c1a291f6c3c63627e7b5fe9d9e8c89167 /nixos/modules/services/misc/plexpy.nix | |
parent | e697f10fc4e5343c9fc3c253efb910fecb6f84da (diff) | |
download | nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar.gz nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar.bz2 nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar.lz nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar.xz nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.tar.zst nixlib-95dc36235ce21ab8563f1ba61a5d80e6c2ea9e3b.zip |
PlexPy service
Diffstat (limited to 'nixos/modules/services/misc/plexpy.nix')
-rw-r--r-- | nixos/modules/services/misc/plexpy.nix | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/plexpy.nix b/nixos/modules/services/misc/plexpy.nix new file mode 100644 index 000000000000..df9f12581247 --- /dev/null +++ b/nixos/modules/services/misc/plexpy.nix @@ -0,0 +1,81 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.plexpy; +in +{ + options = { + services.plexpy = { + enable = mkEnableOption "PlexPy Plex Monitor"; + + dataDir = mkOption { + type = types.str; + default = "/var/lib/plexpy"; + description = "The directory where PlexPy stores its data files."; + }; + + configFile = mkOption { + type = types.str; + default = "/var/lib/plexpy/config.ini"; + description = "The location of PlexPy's config file."; + }; + + port = mkOption { + type = types.int; + default = 8181; + description = "TCP port where PlexPy listens."; + }; + + user = mkOption { + type = types.str; + default = "plexpy"; + description = "User account under which PlexPy runs."; + }; + + group = mkOption { + type = types.str; + default = "nogroup"; + description = "Group under which PlexPy runs."; + }; + + package = mkOption { + type = types.package; + default = pkgs.plexpy; + defaultText = "pkgs.plexpy"; + description = '' + The PlexPy package to use. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.plexpy = { + description = "PlexPy Plex Monitor"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + preStart = '' + test -d "${cfg.dataDir}" || { + echo "Creating initial PlexPy data directory in \"${cfg.dataDir}\"." + mkdir -p "${cfg.dataDir}" + chown ${cfg.user}:${cfg.group} "${cfg.dataDir}" + } + ''; + serviceConfig = { + Type = "simple"; + User = cfg.user; + Group = cfg.group; + PermissionsStartOnly = "true"; + GuessMainPID = "false"; + ExecStart = "${cfg.package}/bin/plexpy --datadir ${cfg.dataDir} --config ${cfg.configFile} --port ${toString cfg.port} --pidfile ${cfg.dataDir}/plexpy.pid --nolaunch"; + Restart = "on-failure"; + }; + }; + + users.extraUsers = mkIf (cfg.user == "plexpy") { + plexpy = { group = cfg.group; uid = config.ids.uids.plexpy; }; + }; + }; +} |