2021-01-11 07:54:33 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
2019-02-28 10:15:28 +00:00
|
|
|
fetchurl,
|
2020-11-26 08:45:16 +00:00
|
|
|
dpkg,
|
2020-11-26 12:47:34 +00:00
|
|
|
writeScript,
|
|
|
|
curl,
|
|
|
|
jq,
|
|
|
|
common-updater-scripts,
|
2019-02-28 10:15:28 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
# 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 {
|
2024-11-25 23:22:04 +00:00
|
|
|
version = "1.41.2.9200-c6bbc1b53";
|
2019-02-28 10:15:28 +00:00
|
|
|
pname = "plexmediaserver";
|
|
|
|
|
|
|
|
# Fetch the source
|
2020-11-26 08:45:16 +00:00
|
|
|
src =
|
|
|
|
if stdenv.hostPlatform.system == "aarch64-linux" then
|
|
|
|
fetchurl {
|
|
|
|
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_arm64.deb";
|
2024-11-25 23:22:04 +00:00
|
|
|
sha256 = "sha256-VTWyeve+Uz3TdWQ06CmZ9w+Gk9jBHP7EuYi0N9DTB4Q=";
|
2020-11-26 08:45:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
fetchurl {
|
|
|
|
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
|
2024-11-25 23:22:04 +00:00
|
|
|
sha256 = "sha256-HmgtnUsDzRIUThYdlZIzhiU02n9jSU7wtwnEA0+r1iQ=";
|
2019-02-28 10:15:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"basedb"
|
|
|
|
];
|
|
|
|
|
2020-11-26 08:45:16 +00:00
|
|
|
nativeBuildInputs = [ dpkg ];
|
2019-02-28 10:15:28 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2021-02-21 10:18:15 +00:00
|
|
|
runHook preInstall
|
2019-02-28 10:15:28 +00:00
|
|
|
mkdir -p "$out/lib"
|
|
|
|
cp -dr --no-preserve='ownership' usr/lib/plexmediaserver $out/lib/
|
|
|
|
|
|
|
|
# Location of the initial Plex plugins database
|
|
|
|
f=$out/lib/plexmediaserver/Resources/com.plexapp.plugins.library.db
|
|
|
|
|
|
|
|
# Store the base database in the 'basedb' output
|
|
|
|
cat $f > $basedb
|
|
|
|
|
|
|
|
# Overwrite the base database in the Plex package with an absolute symlink
|
|
|
|
# to the '/db' file; we create this path in the FHS userenv (see the "plex"
|
|
|
|
# package).
|
|
|
|
ln -fs /db $f
|
2021-02-21 10:18:15 +00:00
|
|
|
runHook postInstall
|
2019-02-28 10:15:28 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# We're running in a FHS userenv; don't patch anything
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
dontStrip = true;
|
|
|
|
dontPatchELF = true;
|
|
|
|
dontAutoPatchelf = true;
|
|
|
|
|
2020-11-26 12:47:34 +00:00
|
|
|
passthru.updateScript = writeScript "${pname}-updater" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
set -eu -o pipefail
|
2021-01-15 07:07:56 +00:00
|
|
|
PATH=${
|
|
|
|
lib.makeBinPath [
|
|
|
|
curl
|
|
|
|
jq
|
|
|
|
common-updater-scripts
|
2024-12-10 19:26:33 +00:00
|
|
|
]
|
2021-01-15 07:07:56 +00:00
|
|
|
}:$PATH
|
2020-11-26 12:47:34 +00:00
|
|
|
|
|
|
|
plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
|
|
|
|
latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
|
|
|
|
|
2021-01-15 07:07:56 +00:00
|
|
|
for platform in ${lib.concatStringsSep " " meta.platforms}; do
|
2020-11-26 12:47:34 +00:00
|
|
|
arch=$(echo $platform | cut -d '-' -f1)
|
|
|
|
dlUrl="$(echo $plexApiJson | jq --arg arch "$arch" -c '.computer.Linux.releases[] | select(.distro == "debian") | select(.build | contains($arch)) .url' | tr -d '"\n')"
|
|
|
|
|
|
|
|
latestSha="$(nix-prefetch-url $dlUrl)"
|
|
|
|
|
2024-06-09 17:46:03 +00:00
|
|
|
update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform --ignore-same-version
|
2020-11-26 12:47:34 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://plex.tv/";
|
2022-06-11 11:39:29 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2019-02-28 10:15:28 +00:00
|
|
|
license = licenses.unfree;
|
2020-11-26 08:45:16 +00:00
|
|
|
platforms = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
2019-02-28 10:15:28 +00:00
|
|
|
maintainers = with maintainers; [
|
2020-11-15 16:26:38 +00:00
|
|
|
badmutex
|
2019-02-28 10:15:28 +00:00
|
|
|
forkk
|
|
|
|
lnl7
|
|
|
|
pjones
|
|
|
|
thoughtpolice
|
2021-07-22 16:31:57 +00:00
|
|
|
MayNiklas
|
2019-02-28 10:15:28 +00:00
|
|
|
];
|
|
|
|
description = "Media library streaming server";
|
|
|
|
longDescription = ''
|
|
|
|
Plex is a media server which allows you to store your media and play it
|
|
|
|
back across many different devices.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|