move pkgs

This commit is contained in:
Vivian 2024-01-03 15:50:11 +01:00
parent 84f07ef08f
commit af2b5a14f2
14 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,3 @@
{ plex, plexRaw-plexpass }:
# Copied from: https://github.com/tadfisher/flake/blob/ed949a619236ba30f0be614fed804abdf1e8005b/pkgs/plex-plexpass/default.nix
plex.override { plexRaw = plexRaw-plexpass; }

15
pkgs/plex-pass/raw.nix Normal file
View file

@ -0,0 +1,15 @@
{ lib, stdenv, plexRaw, fetchurl }:
let
sources = builtins.fromJSON (builtins.readFile ./sources.json);
source = lib.findFirst (x: x.platform == stdenv.hostPlatform.system)
(throw "unsupported platform: ${stdenv.hostPlatform.system}")
sources;
in
plexRaw.overrideAttrs (attrs: {
pname = attrs.pname + "-plexpass";
inherit (source) version;
src = fetchurl {
inherit (source) url;
sha256 = source.hash;
};
})

View file

@ -0,0 +1,14 @@
[
{
"version": "1.40.0.7775",
"platform": "aarch64-linux",
"url": "https://downloads.plex.tv/plex-media-server-new/1.40.0.7775-456fbaf97/debian/plexmediaserver_1.40.0.7775-456fbaf97_arm64.deb",
"hash": "0awannq36c5zgp2hln6g90yc44qf2sm0cq14wp7ck4yvs7wr5rwh"
},
{
"version": "1.40.0.7775",
"platform": "x86_64-linux",
"url": "https://downloads.plex.tv/plex-media-server-new/1.40.0.7775-456fbaf97/debian/plexmediaserver_1.40.0.7775-456fbaf97_amd64.deb",
"hash": "0zkz2w2rjngkdamsdp10j1gxd197kqrlqdm6z0sfvnzf7zvlr7v6"
}
]

33
pkgs/plex-pass/update.sh Executable file
View file

@ -0,0 +1,33 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p vault curl jq
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