From c9222e23a9187e9345718c2fff5b4ea907f022e0 Mon Sep 17 00:00:00 2001 From: Jeff Huffman Date: Sun, 5 Feb 2023 22:10:58 -0500 Subject: [PATCH] vieb: add update script --- .../networking/browsers/vieb/default.nix | 11 +++-- .../networking/browsers/vieb/pin.json | 4 ++ .../networking/browsers/vieb/update.sh | 41 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/networking/browsers/vieb/pin.json create mode 100755 pkgs/applications/networking/browsers/vieb/update.sh diff --git a/pkgs/applications/networking/browsers/vieb/default.nix b/pkgs/applications/networking/browsers/vieb/default.nix index 5441c7a58cbd..5a0e81f4a4b8 100644 --- a/pkgs/applications/networking/browsers/vieb/default.nix +++ b/pkgs/applications/networking/browsers/vieb/default.nix @@ -1,14 +1,17 @@ { mkYarnPackage, fetchFromGitHub, electron, makeWrapper, makeDesktopItem, lib }: +let + srcInfo = builtins.fromJSON (builtins.readFile ./pin.json); +in mkYarnPackage rec { pname = "vieb"; - version = "9.5.0"; + inherit (srcInfo) version; src = fetchFromGitHub { owner = "Jelmerro"; repo = pname; rev = version; - sha256 = "sha256-SWHjzrEvRlTn4HJnT81Le4KsFDypN3QH3F/z7zZ8p3E="; + inherit (srcInfo) sha256; }; packageJSON = ./package.json; @@ -52,11 +55,13 @@ mkYarnPackage rec { distPhase = ":"; # disable useless $out/tarballs directory + passthru.updateScript = ./update.sh; + meta = with lib; { homepage = "https://vieb.dev/"; changelog = "https://github.com/Jelmerro/Vieb/releases/tag/${version}"; description = "Vim Inspired Electron Browser"; - maintainers = with maintainers; [ gebner fortuneteller2k ]; + maintainers = with maintainers; [ gebner fortuneteller2k tejing ]; platforms = platforms.unix; license = licenses.gpl3Plus; }; diff --git a/pkgs/applications/networking/browsers/vieb/pin.json b/pkgs/applications/networking/browsers/vieb/pin.json new file mode 100644 index 000000000000..5841283be6d5 --- /dev/null +++ b/pkgs/applications/networking/browsers/vieb/pin.json @@ -0,0 +1,4 @@ +{ + "version": "9.5.0", + "sha256": "sha256-SWHjzrEvRlTn4HJnT81Le4KsFDypN3QH3F/z7zZ8p3E=" +} diff --git a/pkgs/applications/networking/browsers/vieb/update.sh b/pkgs/applications/networking/browsers/vieb/update.sh new file mode 100755 index 000000000000..3efc25235891 --- /dev/null +++ b/pkgs/applications/networking/browsers/vieb/update.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p bash wget jq yarn yarn2nix nix-prefetch-github + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +if [ "$#" -gt 1 ] || [[ "${1:-}" == -* ]]; then + echo "Regenerates packaging data for the vieb package." + echo "Usage: $0 [git release tag]" + exit 1 +fi + +version="${1:-}" + +if [ -z "$version" ]; then + version="$(wget -O- "https://api.github.com/repos/Jelmerro/Vieb/releases?per_page=1" | jq -r '.[0].tag_name')" +fi + +SRC="https://raw.githubusercontent.com/Jelmerro/Vieb/$version" + +tmpdir="$(mktemp -d --tmpdir update-vieb-XXXXXX)" +pushd "$tmpdir" + +wget "$SRC/package-lock.json" +wget "$SRC/package.json" +yarn import +yarn2nix >yarn.nix + +popd +cp -ft . "$tmpdir/"{package.json,yarn.lock,yarn.nix} +rm -rf "$tmpdir" + +src_hash=$(nix-prefetch-github Jelmerro Vieb --rev "${version}" | jq -r .sha256) + +cat > pin.json << EOF +{ + "version": "$version", + "sha256": "$src_hash" +} +EOF