Plex on NixOS is simple enough, the community wiki and the Nixpkgs search provide enough guidance to get up and running.
I've been digging into further customization and I needed to install a plugin which is usually just a git clone blah blah blah
but this is NixOS. A blood sacrifice is required.
Here's the solution I came up with.
# Plex plugin clone service
systemd.services.clone-audnexus-plugin = {
description = "Clone Audnexus Plex Plugin";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
User = "plex";
Group = "plex";
};
script = ''
PLUGIN_DIR="/var/lib/plex/Plex Media Server/Plug-ins/Audnexus.bundle"
if [ -d "$PLUGIN_DIR" ]; then
cd "$PLUGIN_DIR"
${pkgs.git}/bin/git pull
else
mkdir -p "/var/lib/plex/Plex Media Server/Plug-ins"
cd "/var/lib/plex/Plex Media Server/Plug-ins"
${pkgs.git}/bin/git clone https://github.com/djdembeck/Audnexus.bundle.git
fi
'';
}
Note: You'll need to have git
installed to make this work correctly.
This can modified for other plugins and could probably be parametrized to take a list of plugins.