diff options
author | Forkk <forkk@forkk.net> | 2015-04-16 13:15:59 -0500 |
---|---|---|
committer | Forkk <forkk@forkk.net> | 2015-04-17 12:11:30 -0500 |
commit | 079da8cdcd8efb525bc8ece8217bf1f667d1e39b (patch) | |
tree | 7f20618e1bf649d6e6354183acc14ac2692ac64a /pkgs/servers/plex | |
parent | d8cd5d34aeae52487f304844b2f46cdb87c942c1 (diff) |
plex: init at 0.9.11.16.958
Added a package and module for Plex Media Server, an application for managing media collections across multiple devices.
Diffstat (limited to 'pkgs/servers/plex')
-rw-r--r-- | pkgs/servers/plex/default.nix | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/pkgs/servers/plex/default.nix b/pkgs/servers/plex/default.nix new file mode 100644 index 0000000000000..62334de1b5672 --- /dev/null +++ b/pkgs/servers/plex/default.nix @@ -0,0 +1,65 @@ +{ stdenv, fetchurl, rpmextract, glibc +, dataDir ? "/var/lib/plex" # Plex's data directory must be baked into the package due to symlinks. +}: + +stdenv.mkDerivation rec { + name = "plex-${version}"; + version = "0.9.11.16.958"; + vsnHash = "80f1748"; + + src = fetchurl { + url = "https://downloads.plex.tv/plex-media-server/${version}-${vsnHash}/plexmediaserver-${version}-${vsnHash}.x86_64.rpm"; + sha256 = "1wrl654nk10i9p01cgy9fqiqalxyl718qhp4kjnxvcwafayxkp26"; + }; + + buildInputs = [ rpmextract glibc ]; + + phases = [ "unpackPhase" "installPhase" "fixupPhase" "distPhase" ]; + + unpackPhase = '' + rpmextract $src + ''; + + installPhase = '' + install -d $out/usr/lib + cp -dr --no-preserve='ownership' usr/lib/plexmediaserver $out/usr/lib/ + + # Now we need to patch up the executables and libraries to work on Nix. + # Side note: PLEASE don't put spaces in your binary names. This is stupid. + for bin in "Plex Media Server" "Plex DLNA Server" "Plex Media Scanner"; do + patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin" + patchelf --set-rpath "$out/usr/lib/plexmediaserver" "$out/usr/lib/plexmediaserver/$bin" + done + + find $out/usr/lib/plexmediaserver/Resources -type f -a -perm +0100 \ + -print -exec patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" '{}' \; + + + # Our next problem is the "Resources" directory in /usr/lib/plexmediaserver. + # This is ostensibly a skeleton directory, which contains files that Plex + # copies into its folder in /var. Unfortunately, there are some SQLite + # databases in the directory that are opened at startup. Since these + # database files are read-only, SQLite chokes and Plex fails to start. To + # solve this, we keep the resources directory in the Nix store, but we + # rename the database files and replace the originals with symlinks to + # /var/lib/plex. Then, in the systemd unit, the base database files are + # copied to /var/lib/plex before starting Plex. + RSC=$out/usr/lib/plexmediaserver/Resources + for db in "com.plexapp.plugins.library.db"; do + mv $RSC/$db $RSC/base_$db + ln -s ${dataDir}/.skeleton/$db $RSC/$db + done + ''; + + meta = with stdenv.lib; { + homepage = http://plex.tv/; + license = licenses.unfree; + platforms = platforms.linux; + maintainers = with stdenv.lib.maintainers; [ forkk ]; + description = "Media / DLNA server"; + longDescription = '' + Plex is a media server which allows you to store your media and play it + back across many different devices. + ''; + }; +} |