Skip to content

Commit

Permalink
plex: 1.41.0.8994-f2c27da23 -> 1.41.2.9200-c6bbc1b53
Browse files Browse the repository at this point in the history
  • Loading branch information
MayNiklas committed Dec 15, 2024
1 parent 82c0157 commit 7f12d31
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 41 deletions.
74 changes: 56 additions & 18 deletions packages/plex/default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# The actual Plex package that we run is a FHS userenv of the "raw" package.
{ stdenv
, buildFHSUserEnv
, writeScript
, plexRaw

# Old argument for overriding the Plex data directory; not used for this
# version of Plex, but still around for backwards-compatibility.
, dataDir ? "/var/lib/plex"
{
stdenv,
buildFHSEnv,
writeScript,
plexRaw,

# Old argument for overriding the Plex data directory; not used for this
# version of Plex, but still around for backwards-compatibility.
dataDir ? "/var/lib/plex",
}:

buildFHSUserEnv {
name = "plexmediaserver";
inherit (plexRaw) meta;
buildFHSEnv {
pname = "plexmediaserver";

inherit (plexRaw) version meta;

# Plex does some magic to detect if it is already running.
# The separate PID namespace somehow breaks this and Plex is thinking it's already
# running and refuses to start.
unsharePid = false;

# This script is run when we start our Plex binary
runScript = writeScript "plex-run-script" ''
Expand Down Expand Up @@ -63,13 +70,10 @@ buildFHSUserEnv {
test -d "$pluginDir" || mkdir -p "$pluginDir"
# First, remove all of the symlinks in the plugins directory.
echo "Removing old symlinks"
for f in $(ls "$pluginDir/"); do
if [[ -L "$pluginDir/$f" ]]; then
echo "Removing plugin symlink: $pluginDir/$f"
rm "$pluginDir/$f"
fi
done
while IFS= read -r -d $'\0' f; do
echo "Removing plugin symlink: $f"
rm "$f"
done < <(find "$pluginDir" -type l -print0)
echo "Symlinking plugins"
IFS=':' read -ra pluginsArray <<< "$PLEX_PLUGINS"
Expand All @@ -87,6 +91,40 @@ buildFHSUserEnv {
done
fi
if [[ -n "''${PLEX_SCANNERS:-}" ]]; then
for scannerType in Common Movies Music Series; do
echo "Preparing $scannerType scanners directory"
scannerDir="$PLEX_DATADIR/Plex Media Server/Scanners/$scannerType"
test -d "$scannerDir" || mkdir -p "$scannerDir"
# First, remove all of the symlinks in the scanners directory.
echo "Removing old symlinks"
while IFS= read -r -d $'\0' f; do
echo "Removing scanner symlink: $f"
rm "$f"
done < <(find "$scannerDir" -type l -print0)
echo "Symlinking scanners"
IFS=':' read -ra scannersArray <<< "$PLEX_SCANNERS"
for path in "''${scannersArray[@]}"; do
# The provided source should contain a 'Scanners' directory; symlink
# from inside that.
subpath="$path/Scanners/$scannerType"
while IFS= read -r -d $'\0' file; do
dest="$scannerDir/$(basename "$file")"
if [[ -f "$dest" || -L "$dest" ]]; then
echo "Error symlinking scanner from $file to $dest: file or directory already exists"
else
echo "Symlinking scanner at: $file"
ln -s "$file" "$dest"
fi
done < <(find "$subpath" -type f -print0)
done
done
fi
# Tell Plex to use the data directory as the "Application Support"
# directory, otherwise it tries to write things into the user's home
# directory.
Expand Down
60 changes: 37 additions & 23 deletions packages/plex/raw.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,45 @@
# version in the repositories:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/plex/raw.nix
#
{ lib, stdenv
, fetchurl
, dpkg
, writeScript
, curl
, jq
, common-updater-scripts
{
lib,
stdenv,
fetchurl,
dpkg,
writeScript,
curl,
jq,
common-updater-scripts,
}:

# The raw package that fetches and extracts the Plex RPM. Override the source
# and version of this derivation if you want to use a Plex Pass version of the
# server, and the FHS userenv and corresponding NixOS module should
# automatically pick up the changes.
stdenv.mkDerivation rec {
version = "1.41.0.8994-f2c27da23";
version = "1.41.2.9200-c6bbc1b53";
pname = "plexmediaserver";

# Fetch the source
src = if stdenv.hostPlatform.system == "aarch64-linux" then fetchurl {
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_arm64.deb";
sha256 = "118mqmqfpfskqa19869lg9riip64jz0c2jrvnkpdilvzzhy9ngwx";
} else fetchurl {
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
sha256 = "10nis1hk3fc9bvgiz41x4gmgbzlz2cczz47a2x14liqxmiwqwl3v";
};

outputs = [ "out" "basedb" ];
src =
if stdenv.hostPlatform.system == "aarch64-linux" then
fetchurl {
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_arm64.deb";
sha256 = "sha256-VTWyeve+Uz3TdWQ06CmZ9w+Gk9jBHP7EuYi0N9DTB4Q=";
}
else
fetchurl {
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
sha256 = "sha256-HmgtnUsDzRIUThYdlZIzhiU02n9jSU7wtwnEA0+r1iQ=";
};

outputs = [
"out"
"basedb"
];

nativeBuildInputs = [ dpkg ];

unpackPhase = ''
dpkg-deb -R $src .
'';

installPhase = ''
runHook preInstall
mkdir -p "$out/lib"
Expand Down Expand Up @@ -63,7 +68,13 @@ stdenv.mkDerivation rec {
passthru.updateScript = writeScript "${pname}-updater" ''
#!${stdenv.shell}
set -eu -o pipefail
PATH=${lib.makeBinPath [curl jq common-updater-scripts]}:$PATH
PATH=${
lib.makeBinPath [
curl
jq
common-updater-scripts
]
}:$PATH
plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
Expand All @@ -82,7 +93,10 @@ stdenv.mkDerivation rec {
homepage = "https://plex.tv/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
platforms = [ "x86_64-linux" "aarch64-linux" ];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
maintainers = with maintainers; [
badmutex
forkk
Expand Down

0 comments on commit 7f12d31

Please sign in to comment.