nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 100 lines 3.3 kB view raw
1{ lib, stdenv 2, fetchurl 3, dpkg 4, writeScript 5, curl 6, jq 7, common-updater-scripts 8}: 9 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. 14stdenv.mkDerivation rec { 15 version = "1.32.2.7100-248a2daf0"; 16 pname = "plexmediaserver"; 17 18 # Fetch the source 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-bavah27eq+EVDSJaOLzrjbW8zS/0jCDUeifSTewxSec="; 22 } else fetchurl { 23 url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb"; 24 sha256 = "sha256-sXIK72mjYvmn5k6g4nxdR794ie78F8bSnRA2oLkF2Vc="; 25 }; 26 27 outputs = [ "out" "basedb" ]; 28 29 nativeBuildInputs = [ dpkg ]; 30 31 unpackPhase = '' 32 dpkg-deb -R $src . 33 ''; 34 35 installPhase = '' 36 runHook preInstall 37 mkdir -p "$out/lib" 38 cp -dr --no-preserve='ownership' usr/lib/plexmediaserver $out/lib/ 39 40 # Location of the initial Plex plugins database 41 f=$out/lib/plexmediaserver/Resources/com.plexapp.plugins.library.db 42 43 # Store the base database in the 'basedb' output 44 cat $f > $basedb 45 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" 48 # package). 49 ln -fs /db $f 50 runHook postInstall 51 ''; 52 53 # We're running in a FHS userenv; don't patch anything 54 dontPatchShebangs = true; 55 dontStrip = true; 56 dontPatchELF = true; 57 dontAutoPatchelf = true; 58 59 passthru.updateScript = writeScript "${pname}-updater" '' 60 #!${stdenv.shell} 61 set -eu -o pipefail 62 PATH=${lib.makeBinPath [curl jq common-updater-scripts]}:$PATH 63 64 plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json) 65 latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')" 66 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')" 70 71 latestSha="$(nix-prefetch-url $dlUrl)" 72 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 77 done 78 ''; 79 80 meta = with lib; { 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; [ 86 badmutex 87 forkk 88 lnl7 89 pjones 90 thoughtpolice 91 maxeaubrey 92 MayNiklas 93 ]; 94 description = "Media library streaming server"; 95 longDescription = '' 96 Plex is a media server which allows you to store your media and play it 97 back across many different devices. 98 ''; 99 }; 100}