add plexpass package
This commit is contained in:
parent
fc0f5c6cfa
commit
3eb4fa4fb3
7 changed files with 69 additions and 2 deletions
32
nixos/pkgs/plex-pass/update.sh
Executable file
32
nixos/pkgs/plex-pass/update.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
shopt -s extglob
|
||||
set -eu -o pipefail
|
||||
|
||||
path="$(realpath "$(dirname "$0")")"
|
||||
|
||||
declare -A platforms=(
|
||||
[linux-x86_64]=x86_64-linux
|
||||
[linux-aarch64]=aarch64-linux
|
||||
)
|
||||
|
||||
token=$(vault kv get -field=plex_token hades_secrets/nixos/plex)
|
||||
manifest=$(curl -s "https://plex.tv/api/downloads/5.json?channel=plexpass" -H "X-Plex-Token: ${token}")
|
||||
version=$(echo "$manifest" | jq -r '.computer.Linux.version | split("-") | .[0]')
|
||||
|
||||
tmp="$path/sources.tmp.json"
|
||||
echo '' >$tmp
|
||||
|
||||
for arch in "${!platforms[@]}"; do
|
||||
url="$(echo "$manifest" | jq --arg arch "$arch" -r '.computer.Linux.releases[] | select(.distro == "debian" and .build == $arch) .url')"
|
||||
hash="$(nix-prefetch-url "$url")"
|
||||
nixPlatform=${platforms[$arch]}
|
||||
jq --arg version $version \
|
||||
--arg platform $nixPlatform \
|
||||
--arg url "$url" \
|
||||
--arg hash $hash \
|
||||
-n '$ARGS.named' >>$tmp
|
||||
done
|
||||
|
||||
jq -s '.' $tmp >"$path/sources.json"
|
||||
rm $tmp
|
Loading…
Add table
Add a link
Reference in a new issue