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