depot/nix/pkgs/updateplexpass.sh

30 lines
952 B
Bash
Executable file

#!/bin/sh
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0
VERSION_JSON_URL="https://plex.tv/pms/downloads/5.json?channel=plexpass&X-Plex-Token=$(vault kv get -field=token kv/apps/plex-pass)"
alias jq="nix run depot.pkgs.jq -c 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 == "redhat")' <<< "$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, ... }:
(pkgs.plex.override {
plexRaw = (pkgs.plexRaw.overrideAttrs (oldAttrs: rec {
version = "${VERSION}";
src = pkgs.fetchurl {
url = "${URL}";
sha256 = "${URL_HASH}";
};
}));
})
EOF