7 , common-updater-scripts
10 # The raw package that fetches and extracts the Plex RPM. Override the source
11 # and version of this derivation if you want to use a Plex Pass version of the
12 # server, and the FHS userenv and corresponding NixOS module should
13 # automatically pick up the changes.
14 stdenv.mkDerivation rec {
15 version = "1.41.2.9200-c6bbc1b53";
16 pname = "plexmediaserver";
19 src = if stdenv.hostPlatform.system == "aarch64-linux" then fetchurl {
20 url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_arm64.deb";
21 sha256 = "sha256-VTWyeve+Uz3TdWQ06CmZ9w+Gk9jBHP7EuYi0N9DTB4Q=";
23 url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
24 sha256 = "sha256-HmgtnUsDzRIUThYdlZIzhiU02n9jSU7wtwnEA0+r1iQ=";
27 outputs = [ "out" "basedb" ];
29 nativeBuildInputs = [ dpkg ];
34 cp -dr --no-preserve='ownership' usr/lib/plexmediaserver $out/lib/
36 # Location of the initial Plex plugins database
37 f=$out/lib/plexmediaserver/Resources/com.plexapp.plugins.library.db
39 # Store the base database in the 'basedb' output
42 # Overwrite the base database in the Plex package with an absolute symlink
43 # to the '/db' file; we create this path in the FHS userenv (see the "plex"
49 # We're running in a FHS userenv; don't patch anything
50 dontPatchShebangs = true;
53 dontAutoPatchelf = true;
55 passthru.updateScript = writeScript "${pname}-updater" ''
58 PATH=${lib.makeBinPath [curl jq common-updater-scripts]}:$PATH
60 plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
61 latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
63 for platform in ${lib.concatStringsSep " " meta.platforms}; do
64 arch=$(echo $platform | cut -d '-' -f1)
65 dlUrl="$(echo $plexApiJson | jq --arg arch "$arch" -c '.computer.Linux.releases[] | select(.distro == "debian") | select(.build | contains($arch)) .url' | tr -d '"\n')"
67 latestSha="$(nix-prefetch-url $dlUrl)"
69 update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform --ignore-same-version
74 homepage = "https://plex.tv/";
75 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
76 license = licenses.unfree;
77 platforms = [ "x86_64-linux" "aarch64-linux" ];
78 maintainers = with maintainers; [
86 description = "Media library streaming server";
88 Plex is a media server which allows you to store your media and play it
89 back across many different devices.