37 lines
1.1 KiB
Bash
Executable file
37 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
[ -z "$PLEX_PASS_TOKEN" ] && PLEX_PASS_TOKEN="$(vault kv get -field=token kv/apps/plex-pass)"
|
|
VERSION_JSON_URL="https://plex.tv/pms/downloads/5.json?channel=plexpass&X-Plex-Token=${PLEX_PASS_TOKEN}"
|
|
alias jq="nix run -f '<depot>' pkgs.jq --"
|
|
VERSION_JSON="$(curl "$VERSION_JSON_URL")"
|
|
|
|
VERSION="$(jq -r '.computer.Linux.version' <<< "$VERSION_JSON")"
|
|
RELEASE_JSON="$(jq '.computer.Linux.releases[] | select(.build == "linux-x86_64" and .distro == "debian")' <<< "$VERSION_JSON")"
|
|
URL="$(jq -r '.url' <<< "$RELEASE_JSON")"
|
|
URL_HASH="$(nix-prefetch-url "$URL")"
|
|
|
|
cat <<EOF
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
{ pkgs, ... }:
|
|
let
|
|
version = "${VERSION}";
|
|
src = pkgs.fetchurl {
|
|
url = "${URL}";
|
|
hash = "sha256:${URL_HASH}";
|
|
};
|
|
in
|
|
(pkgs.plex.override {
|
|
plexRaw = (pkgs.plexRaw.overrideAttrs (oldAttrs: rec {
|
|
inherit version src;
|
|
}));
|
|
}).overrideAttrs (oldAttrs: {
|
|
name = "plexmediaserver-\${version}";
|
|
inherit version src;
|
|
})
|
|
EOF
|