plex-htpc: init at 1.71.1 (#400661)

authored by pyrox.dev and committed by GitHub 009f373a a58135c7

+237
+166
pkgs/by-name/pl/plex-htpc/package.nix
··· 1 + { 2 + alsa-lib, 3 + autoPatchelfHook, 4 + buildFHSEnv, 5 + elfutils, 6 + extraEnv ? { }, 7 + fetchurl, 8 + ffmpeg_6-headless, 9 + lib, 10 + libdrm, 11 + libgbm, 12 + libpulseaudio, 13 + libva, 14 + libxkbcommon, 15 + libxml2_13, 16 + makeShellWrapper, 17 + minizip, 18 + nss, 19 + squashfsTools, 20 + stdenv, 21 + writeShellScript, 22 + xkeyboard_config, 23 + xorg, 24 + }: 25 + let 26 + pname = "plex-htpc"; 27 + version = "1.71.1"; 28 + rev = "73"; 29 + meta = { 30 + homepage = "https://plex.tv/"; 31 + description = "Plex HTPC client for the big screen"; 32 + longDescription = '' 33 + Plex HTPC for Linux is your client for playing on your Linux computer 34 + connected to the big screen. It features a 10-foot interface with a 35 + powerful playback engine. 36 + ''; 37 + maintainers = with lib.maintainers; [ detroyejr ]; 38 + license = lib.licenses.unfree; 39 + platforms = [ "x86_64-linux" ]; 40 + mainProgram = "plex-htpc"; 41 + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 42 + }; 43 + plex-htpc = stdenv.mkDerivation { 44 + inherit pname version meta; 45 + 46 + src = fetchurl { 47 + url = "https://api.snapcraft.io/api/v1/snaps/download/81OP06hEXlwmMrpMAhe5hyLy5bQ9q6Kz_${rev}.snap"; 48 + hash = "sha512-n9pXRx8s6AwhIJm7PmUIOB8pXqzyNFzdmwJMonQ4WzWvA5tPI27x0slQ6WUxRBQJoLScGckyGAFxIGWRylNr3g=="; 49 + }; 50 + 51 + nativeBuildInputs = [ 52 + autoPatchelfHook 53 + makeShellWrapper 54 + squashfsTools 55 + ]; 56 + 57 + buildInputs = [ 58 + elfutils 59 + ffmpeg_6-headless 60 + libgbm 61 + libpulseaudio 62 + libva 63 + libxkbcommon 64 + libxml2_13 65 + minizip 66 + nss 67 + stdenv.cc.cc 68 + xorg.libXcomposite 69 + xorg.libXdamage 70 + xorg.libXinerama 71 + xorg.libXrandr 72 + xorg.libXrender 73 + xorg.libXtst 74 + xorg.libxshmfence 75 + xorg.xcbutilimage 76 + xorg.xcbutilkeysyms 77 + xorg.xcbutilrenderutil 78 + xorg.xcbutilwm 79 + xorg.xrandr 80 + ]; 81 + 82 + strictDeps = true; 83 + 84 + unpackPhase = '' 85 + runHook preUnpack 86 + unsquashfs "$src" 87 + cd squashfs-root 88 + runHook postUnpack 89 + ''; 90 + 91 + dontStrip = true; 92 + dontWrapQtApps = true; 93 + 94 + installPhase = '' 95 + runHook preInstall 96 + 97 + cp -r . $out 98 + rm -r $out/etc 99 + rm -r $out/usr 100 + 101 + # flatpak removes these during installation. 102 + rm -r $out/lib/dri 103 + rm $out/lib/libpciaccess.so* 104 + rm $out/lib/libswresample.so* 105 + rm $out/lib/libva-*.so* 106 + rm $out/lib/libva.so* 107 + rm $out/lib/libEGL.so* 108 + rm $out/lib/libdrm.so* 109 + rm $out/lib/libdrm* 110 + 111 + # Keep some dependencies from the snap. 112 + cp usr/lib/x86_64-linux-gnu/liblcms2.so.2 $out/lib/liblcms2.so.2 113 + cp usr/lib/x86_64-linux-gnu/libjbig.so.0 $out/lib/libjbig.so.0 114 + cp usr/lib/x86_64-linux-gnu/libjpeg.so.8 $out/lib/libjpeg.so.8 115 + cp usr/lib/x86_64-linux-gnu/libpci.so.3 $out/lib/libpci.so.3 116 + cp usr/lib/x86_64-linux-gnu/libsnappy.so.1 $out/lib/libsnappy.so.1 117 + cp usr/lib/x86_64-linux-gnu/libtiff.so.5 $out/lib/libtiff.so.5 118 + cp usr/lib/x86_64-linux-gnu/libwebp.so.6 $out/lib/libwebp.so.6 119 + cp usr/lib/x86_64-linux-gnu/libxkbfile.so.1 $out/lib/libxkbfile.so.1 120 + cp usr/lib/x86_64-linux-gnu/libxslt.so.1 $out/lib/libxslt.so.1 121 + 122 + runHook postInstall 123 + ''; 124 + }; 125 + in 126 + buildFHSEnv { 127 + inherit pname version meta; 128 + targetPkgs = pkgs: [ 129 + alsa-lib 130 + libdrm 131 + xkeyboard_config 132 + ]; 133 + 134 + extraInstallCommands = '' 135 + mkdir -p $out/share/applications $out/share/icons/hicolor/scalable/apps 136 + install -m 444 -D ${plex-htpc}/meta/gui/plex-htpc.desktop $out/share/applications/plex-htpc.desktop 137 + substituteInPlace $out/share/applications/plex-htpc.desktop \ 138 + --replace-fail \ 139 + 'Icon=''${SNAP}/meta/gui/icon.png' \ 140 + 'Icon=${plex-htpc}/meta/gui/icon.png' 141 + ''; 142 + 143 + runScript = writeShellScript "plex-htpc.sh" '' 144 + # Widevine won't download unless this directory exists. 145 + mkdir -p $HOME/.cache/plex/ 146 + 147 + # Copy the sqlite plugin database on first run. 148 + PLEX_DB="$HOME/.local/share/plex/Plex Media Server/Plug-in Support/Databases" 149 + if [[ ! -d "$PLEX_DB" ]]; then 150 + mkdir -p "$PLEX_DB" 151 + cp "${plex-htpc}/resources/com.plexapp.plugins.library.db" "$PLEX_DB" 152 + fi 153 + 154 + # db files should have write access. 155 + chmod --recursive 750 "$PLEX_DB" 156 + 157 + # These environment variables sometimes silently cause plex to crash. 158 + unset QT_QPA_PLATFORM QT_STYLE_OVERRIDE 159 + 160 + set -o allexport 161 + ${lib.toShellVars extraEnv} 162 + set +o allexport 163 + exec ${plex-htpc}/Plex.sh 164 + ''; 165 + passthru.updateScript = ./update.sh; 166 + }
+71
pkgs/by-name/pl/plex-htpc/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #! nix-shell -i bash -p curl jq git gnused gnugrep 3 + 4 + 5 + # executing this script without arguments will 6 + # - find the newest stable plex-htpc version avaiable on snapcraft (https://snapcraft.io/plex-htpc) 7 + # - read the current plex-htpc version from the current nix expression 8 + # - update the nix expression if the versions differ 9 + # - try to build the updated version, exit if that fails 10 + # - give instructions for upstreaming 11 + 12 + # As an optional argument you can specify the snapcraft channel to update to. 13 + # Default is `stable` and only stable updates should be pushed to nixpkgs. For 14 + # testing you may specify `candidate` or `edge`. 15 + 16 + 17 + channel="${1:-stable}" # stable/candidate/edge 18 + nixpkgs="$(git rev-parse --show-toplevel)" 19 + plex_nix="$nixpkgs/pkgs/by-name/pl/plex-htpc/package.nix" 20 + 21 + 22 + # 23 + # find the newest stable plex-htpc version avaiable on snapcraft 24 + # 25 + 26 + # create bash array from snap info 27 + snap_info=($( 28 + curl -s -H 'X-Ubuntu-Series: 16' \ 29 + "https://api.snapcraft.io/api/v1/snaps/details/plex-htpc?channel=$channel" \ 30 + | jq --raw-output \ 31 + '.revision,.download_sha512,.version,.last_updated' 32 + )) 33 + 34 + # "revision" is the actual version identifier on snapcraft, the "version" is 35 + # just for human consumption. Revision is just an integer that gets increased 36 + # by one every (stable or unstable) release. 37 + revision="${snap_info[0]}" 38 + # We need to escape the slashes 39 + hash="$(nix-hash --to-sri --type sha512 ${snap_info[1]} | sed 's|/|\\/|g')" 40 + upstream_version="${snap_info[2]}" 41 + last_updated="${snap_info[3]}" 42 + echo "Latest $channel release is $upstream_version from $last_updated." 43 + # 44 + # read the current plex-htpc version from the currently *committed* nix expression 45 + # 46 + 47 + current_version=$( 48 + grep 'version\s*=' "$plex_nix" \ 49 + | sed -Ene 's/.*"(.*)".*/\1/p' 50 + ) 51 + 52 + echo "Current version: $current_version" 53 + 54 + # 55 + # update the nix expression if the versions differ 56 + # 57 + 58 + if [[ "$current_version" == "$upstream_version" ]]; then 59 + echo "Plex is already up-to-date" 60 + exit 0 61 + fi 62 + 63 + echo "Updating from ${current_version} to ${upstream_version}, released on ${last_updated}" 64 + 65 + # search-and-replace revision, hash and version 66 + sed --regexp-extended \ 67 + -e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \ 68 + -e 's/hash\s*=\s*"[^"]*"\s*;/hash = "'"${hash}"'";/' \ 69 + -e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \ 70 + -i "$plex_nix" 71 +