add plexpass package
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Vivian 2023-05-24 16:58:51 +02:00
parent 66cc0c8f34
commit 4d1147f49e
7 changed files with 69 additions and 2 deletions

View file

@ -54,6 +54,7 @@
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ (import ./nixos/pkgs) vault-secrets.overlay nur.overlay ];
};
@ -147,6 +148,7 @@
nil
vault
yamllint
jq
(vault-push-approle-envs self { })
(vault-push-approles self { })
fast-repl

View file

@ -16,8 +16,7 @@ in {
gimp
inputs.comma.packages.${pkgs.system}.default
inputs.webcord.packages.${pkgs.system}.default
jetbrains.clion
jetbrains.idea-ultimate
# jetbrains.clion
kdenlive
mullvad-vpn
neofetch

View file

@ -21,5 +21,9 @@ _final: prev: {
platformio.platformio-ide =
prev.callPackage ./vscode-extensions/platformio.nix { };
};
};
plex-plexpass = prev.callPackage ./plex-pass { };
plexRaw-plexpass = prev.callPackage ./plex-pass/raw.nix { };
}

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; }

View file

@ -0,0 +1,13 @@
{ 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";
version = source.version;
src = fetchurl {
inherit (source) url;
sha256 = source.hash;
};
})

View file

@ -0,0 +1,14 @@
[
{
"version": "1.32.2.7100",
"platform": "aarch64-linux",
"url": "https://downloads.plex.tv/plex-media-server-new/1.32.2.7100-248a2daf0/debian/plexmediaserver_1.32.2.7100-248a2daf0_arm64.deb",
"hash": "1rs967n4vli7gba2137l5z6vrdcdxfy3hni21lay3ayyds3xmavd"
},
{
"version": "1.32.2.7100",
"platform": "x86_64-linux",
"url": "https://downloads.plex.tv/plex-media-server-new/1.32.2.7100-248a2daf0/debian/plexmediaserver_1.32.2.7100-248a2daf0_amd64.deb",
"hash": "0myr0nws0dhhkp9cc5zwxs4pigs7bmyf582fwskzjqm3d7phlwmi"
}
]

32
nixos/pkgs/plex-pass/update.sh Executable file
View 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