mochi: add updateScript

This commit is contained in:
Piotr Kwiecinski
2026-02-08 12:25:10 +01:00
parent 02740f4f78
commit a30ba61b87
2 changed files with 28 additions and 0 deletions
+2
View File
@@ -31,6 +31,8 @@ let
substituteInPlace $out/share/applications/${pname}.desktop \
--replace-fail 'Exec=AppRun --no-sandbox' 'Exec=${pname}'
'';
passthru.updateScript = ./update.sh;
};
darwin = stdenv.mkDerivation {
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl nix common-updater-scripts
set -euo pipefail
latestVersion=$(curl -Ls https://mochi.cards/ | grep -oP 'Mochi-\K[0-9]+\.[0-9]+\.[0-9]+(?=\.AppImage)' | head -1)
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; mochi.version" | tr -d '"')
echo "latest version: $latestVersion"
echo "current version: $currentVersion"
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
# Update version and hash for x86_64-linux (AppImage)
update-source-version mochi "$latestVersion" --system=x86_64-linux
# Update hashes for darwin systems
for system in x86_64-darwin aarch64-darwin; do
url=$(nix-instantiate --eval --json -E "with import ./. { system = \"$system\"; }; mochi.src.url" | tr -d '"')
hash=$(nix-prefetch-url "$url")
sriHash=$(nix --extra-experimental-features nix-command hash convert --hash-algo sha256 --to sri "$hash")
update-source-version mochi "$latestVersion" "$sriHash" --system="$system" --ignore-same-version
done