From 978d82014ed25e97a4743e456effaa5455e559c3 Mon Sep 17 00:00:00 2001 From: Benjamin LeBrun <17264415+bglebrun@users.noreply.github.com> Date: Fri, 21 Mar 2025 01:37:27 -0600 Subject: [PATCH] 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 --- .../by-name/mu/multiviewer-for-f1/package.nix | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkgs/by-name/mu/multiviewer-for-f1/package.nix b/pkgs/by-name/mu/multiviewer-for-f1/package.nix index 45a434c5521d..9a9d1019e5cb 100644 --- a/pkgs/by-name/mu/multiviewer-for-f1/package.nix +++ b/pkgs/by-name/mu/multiviewer-for-f1/package.nix @@ -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";