multiviewer-for-f1: add update script (#336246)
* Added update script for multiviewer-for-f1 * Fix update script to perform check Checks if the version pulled from our metadata API is the same as the current version, preventing a pull of the package if an update is not necessary. * nixfmt * nixfmt fix
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
nss,
|
||||
pango,
|
||||
xorg,
|
||||
writeScript,
|
||||
}:
|
||||
let
|
||||
id = "232635194";
|
||||
@@ -93,6 +94,30 @@ stdenvNoCC.mkDerivation rec {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.updateScript = writeScript "update-multiviewer-for-f1" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl common-updater-scripts
|
||||
set -eu -o pipefail
|
||||
|
||||
# Get latest API for packages, store so we only make one request
|
||||
latest=$(curl -s "https://api.multiviewer.app/api/v1/releases/latest/")
|
||||
|
||||
# From the downloaded JSON extract the url, version and id
|
||||
link=$(echo $latest | jq -r '.downloads[] | select(.platform=="linux_deb").url')
|
||||
id=$(echo $latest | jq -r '.downloads[] | select(.platform=="linux_deb").id')
|
||||
version=$(echo $latest | jq -r '.version')
|
||||
|
||||
if [ "$version" != "${version}" ]
|
||||
then
|
||||
# Pre-calculate package hash
|
||||
hash=$(nix-prefetch-url --type sha256 $link)
|
||||
|
||||
# Update ID and version in source
|
||||
update-source-version ${pname} "$id" --version-key=id
|
||||
update-source-version ${pname} "$version" "$hash" --system=x86_64-linux
|
||||
fi
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Unofficial desktop client for F1 TV®";
|
||||
homepage = "https://multiviewer.app";
|
||||
|
||||
Reference in New Issue
Block a user