nixpkgs/pkgs/servers/plex/raw.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
3.3 KiB
Nix
Raw Normal View History

{ lib, stdenv
2019-02-28 13:15:28 +03:00
, fetchurl
2020-11-26 11:45:16 +03:00
, dpkg
2020-11-26 15:47:34 +03:00
, writeScript
, curl
, jq
, common-updater-scripts
2019-02-28 13:15:28 +03: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 {
version = "1.32.4.7195-7c8f9d3b6";
2019-02-28 13:15:28 +03:00
pname = "plexmediaserver";
# Fetch the source
2020-11-26 11:45:16 +03: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";
sha256 = "sha256-Qb684Mm080QudeLG111cLCSRh1CAJ31IjNOO62XkFTs=";
2020-11-26 11:45:16 +03:00
} else fetchurl {
url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb";
sha256 = "sha256-lnkhjzBW9DENCVJNP+4h8fVVUh4LhnJ1XjrCjF3ngKE=";
2019-02-28 13:15:28 +03:00
};
outputs = [ "out" "basedb" ];
2020-11-26 11:45:16 +03:00
nativeBuildInputs = [ dpkg ];
2019-02-28 13:15:28 +03:00
unpackPhase = ''
2020-11-26 11:45:16 +03:00
dpkg-deb -R $src .
2019-02-28 13:15:28 +03:00
'';
installPhase = ''
runHook preInstall
2019-02-28 13:15:28 +03: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
runHook postInstall
2019-02-28 13:15:28 +03:00
'';
# We're running in a FHS userenv; don't patch anything
dontPatchShebangs = true;
dontStrip = true;
dontPatchELF = true;
dontAutoPatchelf = true;
2020-11-26 15:47:34 +03:00
passthru.updateScript = writeScript "${pname}-updater" ''
#!${stdenv.shell}
set -eu -o pipefail
2021-01-15 10:07:56 +03:00
PATH=${lib.makeBinPath [curl jq common-updater-scripts]}:$PATH
2020-11-26 15:47:34 +03:00
plexApiJson=$(curl -sS https://plex.tv/api/downloads/5.json)
latestVersion="$(echo $plexApiJson | jq .computer.Linux.version | tr -d '"\n')"
2021-01-15 10:07:56 +03:00
for platform in ${lib.concatStringsSep " " meta.platforms}; do
2020-11-26 15:47:34 +03: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)"
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version plexRaw 0 $(yes 0 | head -64 | tr -d "\n") --system=$platform
update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform
done
'';
meta = with lib; {
homepage = "https://plex.tv/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
2019-02-28 13:15:28 +03:00
license = licenses.unfree;
2020-11-26 11:45:16 +03:00
platforms = [ "x86_64-linux" "aarch64-linux" ];
2019-02-28 13:15:28 +03:00
maintainers = with maintainers; [
badmutex
2019-02-28 13:15:28 +03:00
forkk
lnl7
pjones
thoughtpolice
2021-07-18 22:23:26 +03:00
maxeaubrey
2021-07-22 19:31:57 +03:00
MayNiklas
2019-02-28 13:15:28 +03: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.
'';
};
}