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.40.2.8395-c67dce28e";
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-ZJqbE9pgflqFVjiDqCED6K5KBk6KHSbkIQllF06jJVQ=";
23 url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
24 sha256 = "sha256-gYRhQIf6RaXgFTaigFW1yJ7ndxRmOP6oJSNnr8o0EBM=";
27 outputs = [ "out" "basedb" ];
29 nativeBuildInputs = [ dpkg ];
38 cp -dr --no-preserve='ownership' usr/lib/plexmediaserver $out/lib/
40 # Location of the initial Plex plugins database
41 f=$out/lib/plexmediaserver/Resources/com.plexapp.plugins.library.db
43 # Store the base database in the 'basedb' output
46 # Overwrite the base database in the Plex package with an absolute symlink
47 # to the '/db' file; we create this path in the FHS userenv (see the "plex"
53 # We're running in a FHS userenv; don't patch anything
54 dontPatchShebangs = true;
57 dontAutoPatchelf = true;
59 passthru.updateScript = writeScript "${pname}-updater" ''
62 PATH=${lib.makeBinPath [curl jq common-updater-scripts]}:$PATH
64 plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
65 latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
67 for platform in ${lib.concatStringsSep " " meta.platforms}; do
68 arch=$(echo $platform | cut -d '-' -f1)
69 dlUrl="$(echo $plexApiJson | jq --arg arch "$arch" -c '.computer.Linux.releases[] | select(.distro == "debian") | select(.build | contains($arch)) .url' | tr -d '"\n')"
71 latestSha="$(nix-prefetch-url $dlUrl)"
73 # The script will not perform an update when the version attribute is up to date from previous platform run
74 # We need to clear it before each run
75 update-source-version plexRaw 0 $(yes 0 | head -64 | tr -d "\n") --system=$platform
76 update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform
81 homepage = "https://plex.tv/";
82 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
83 license = licenses.unfree;
84 platforms = [ "x86_64-linux" "aarch64-linux" ];
85 maintainers = with maintainers; [
94 description = "Media library streaming server";
96 Plex is a media server which allows you to store your media and play it
97 back across many different devices.