From c8def49591b86c54374b315470909e4ed22a116d Mon Sep 17 00:00:00 2001 From: huantian Date: Sat, 1 Jul 2023 14:24:11 -0700 Subject: [PATCH] scarab: add custom updateScript --- pkgs/tools/games/scarab/default.nix | 2 ++ pkgs/tools/games/scarab/update.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 pkgs/tools/games/scarab/update.sh diff --git a/pkgs/tools/games/scarab/default.nix b/pkgs/tools/games/scarab/default.nix index 604213ba1a2f..774d936ea57a 100644 --- a/pkgs/tools/games/scarab/default.nix +++ b/pkgs/tools/games/scarab/default.nix @@ -70,6 +70,8 @@ buildDotnetModule rec { categories = [ "Game" ]; })]; + passthru.updateScript = ./update.sh; + meta = with lib; { description = "Hollow Knight mod installer and manager"; homepage = "https://github.com/fifty-six/Scarab"; diff --git a/pkgs/tools/games/scarab/update.sh b/pkgs/tools/games/scarab/update.sh new file mode 100755 index 000000000000..9ec65acfe47c --- /dev/null +++ b/pkgs/tools/games/scarab/update.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq common-updater-scripts +set -euo pipefail + +new_version="$(curl -s "https://api.github.com/repos/fifty-six/Scarab/releases?per_page=1" | jq -r '.[0].name')" +new_version=${new_version#"v"} +old_version="$(sed -nE 's/^\s*version = "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)";$/\1/p' ./default.nix)" + +if [[ "$new_version" == "$old_version" ]]; then + echo "Up to date" + exit 0 +fi + +update-source-version scarab "$new_version" + +$(nix-build . -A scarab.fetch-deps --no-out-link)