Nixos 19.03 + Plex + Plexpass

I have everything working on my Nix 19.03 server, except getting it to use the plexpass version rather than the “general availability” version. The server is running “19.03.173100.e726e8291b2 (Koi)” and the installed plex version is 1.14.1.5488. My Windows box, that I am trying to replace, is running version 1.16.2.1297. It looks like all I need to do override the ‘services.plex.package’, in /etc/nixos/configuration.nix but I can’t seem to find an example via google, bing, reddit, or stackoverflow. This is really the first time that I have had to deviate from the nixos.stable packages, so I am kind of at a loss. Thank you in advance!

This is how I setup Plex:

  services.plex = {
    enable = true;
    package = pkgs.plex.overrideAttrs (x: let
        # see https://www.plex.tv/media-server-downloads/ for 64bit rpm
        version = "1.13.6.5339-115f087d6";
        sha1 = "7f425470387b7d6b4f31c799dc37f967cef2aae2";
      in {
        name = "plex-${version}";
        src = pkgs.fetchurl {
          url = "https://downloads.plex.tv/plex-media-server/${version}/plexmediaserver-${version}.x86_64.rpm";
          inherit sha1;
        };
      }
    );
  };

though you’ll notice my URL is out of date, too :slight_smile:

Thanks for the quick response and setting me on the right path! I now see what I was doing wrong and a way to go forward. IMHO there is nothing inherently wrong with using an “out of date” version. If it isn’t broke …

I had to make some changes; it looks like the download url changed at some point. This worked for me, for downloading:

url = “https://downloads.plex.tv/plex-media-server-new/{version}/redhat/plexmediaserver-{version}.x86_64.rpm”;

It now creates and installs it, but it fails to run, throwing:

/nix/store/hl8069b969r5aqmcy837a572svhlzhgr-plex-1.16.2.1297-4b7ace214/usr/lib/plexmediaserver/Plex Media Server: error while loading shared libraries: libsoci_core.so: cannot open shared object file: No such file or directory

It looks like the LD_LIBRARY_PATH needs to have “/nix/store/hl8069b969r5aqmcy837a572svhlzhgr-plex-1.16.2.1297-4b7ace214/usr/lib/plexmediaserver/lib/” added to it, but I haven’t figured out how to do that, yet. Thanks again!! It is much further than I was getting before.

Looks like I at the limit of my skills and understanding again. I can use patchelf to find out the rpath:

$ patchelf --print-rpath “/nix/store/rdxn2l48ryg69zbmi9hyd7s7zmj064gn-plex-1.16.2.1297-4b7ace214/usr/lib/plexmediaserver/Plex Media Server”
/nix/store/rdxn2l48ryg69zbmi9hyd7s7zmj064gn-plex-1.16.2.1297-4b7ace214/usr/lib/plexmediaserver

but I am unable to append the **/lib/ directory to it. The nix-store is read-only (as I would expect) and everything I try ends up having no effect. It looks like I need to modify this line in the default.nix directory as so:
Original:
patchelf --set-rpath “$out/usr/lib/plexmediaserver” “$out/usr/lib/plexmediaserver/$bin”

Changed:
patchelf --set-rpath “$out/usr/lib/plexmediaserver:$out/usr/lib/plexmediaserver/lib” “$out/usr/lib/plexmediaserver/$bin”

It looks like it back to running plex under Windows until I figure it out or the current 1.16.* is available to non-subscribers. :frowning: Thanks for the help guys!!

I have updated my nix snippet to the following:

{ config, lib, pkgs, ... }:

{
  imports = [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix> ];

  services.plex = {
    enable = true;
    package = pkgs.plex.overrideAttrs (x: let
        # see https://www.plex.tv/media-server-downloads/ for 64bit rpm
        version = "1.16.2.1321-ad17d5f9e";
        sha1 = "5ad3da87c266e041a14d14731f1d9cae270567f2";
      in {
        name = "plex-${version}";
        src = pkgs.fetchurl {
          url = "https://downloads.plex.tv/plex-media-server-new/${version}/redhat/plexmediaserver-${version}.x86_64.rpm";
          inherit sha1;
        };
      }
    );
  };
}

to reflect the availability of “1.16.2.1321-ad17d5f9e”. I am still seeing the same error when I try to use it, though:
/nix/store/mhxgwr0fdzy02kglywy0igqw8wc0w2bs-plex-1.16.2.1321-ad17d5f9e/usr/lib/plexmediaserver/Plex Media Server: error while loading shared libraries: libsoci_core.so: cannot open shared object file: No such file or directory

That library exists in that tree at “/nix/store/mhxgwr0fdzy02kglywy0igqw8wc0w2bs-plex-1.16.2.1321-ad17d5f9e/usr/lib/plexmediaserver/lib/”. I apologize for being such a newb (this is actually my first and only derivation, as a proof-of-concept for using nixos for further development vs. sinking money into a ubuntu contract. ). The thinking is “the app works fine in a docker container”. I am sure that it is something really simple, for someone who knows exactly what they are doing. I can’t find a way to patchelf the binaries, or add that lib directory to the LD_LIBRARY_PATH. Thanks in advance for any help!

Please can someone help this newbie out? As I said, I am stumped. I am sure one of the nix coding ninjas could tell me what I am doing wrong in, like, 5 seconds. I just have no idea how to modify the LD_LIBRARY_PATH. I tried doing it in my plex snippet above with patchelf but at that point everything is set and it is read-only. I tried to figure out how to add the library to the LD_LIBRARY_PATH, which seems to be the preferred way as it is a FHS userenv. That absolutely doesn’t work :frowning: . Thanks in advance for any help (even a point in a direction would help).

I’ve just recently started using Nix in the past few months, so this might not be the best way to solve the problem, but this is what I’m doing locally:

(where super.unstable is just the unstable channel)

Thanks! That worked for me, once I figured out that I needed to add services.plex.package = pkgs.plexPass to my configuration.nix file, and a little extra sauce from your common.nix file. I can see how it works, and has given me a nice, new direction to look into. New or not doesn’t matter, if you have the answer :smile: