snipaste: add updateScript

This commit is contained in:
L-Trump 2024-10-21 19:56:07 +08:00
parent 77514565ae
commit 117bafd4d2
2 changed files with 17 additions and 0 deletions

View File

@ -12,6 +12,8 @@ appimageTools.wrapType2 rec {
hash = "sha256-u9e2d9ZpHDbDIsFkseOdJX2Kspn9TkhFfZxbeielDA8="; hash = "sha256-u9e2d9ZpHDbDIsFkseOdJX2Kspn9TkhFfZxbeielDA8=";
}; };
passthru.updateScript = ./update.sh;
meta = { meta = {
description = "Screenshot tools"; description = "Screenshot tools";
homepage = "https://www.snipaste.com/"; homepage = "https://www.snipaste.com/";

View File

@ -0,0 +1,15 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl coreutils jq common-updater-scripts
latestTag=$(curl -sSfL https://www.snipaste.com/linux_version | jq -r ".subject")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; snipaste.version" | tr -d '"')
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
prefetch=$(nix-prefetch-url "https://download.snipaste.com/archives/Snipaste-$latestVersion-x86_64.AppImage")
hash=$(nix-hash --type sha256 --to-sri "$prefetch")
update-source-version snipaste "$latestVersion" "$hash" --ignore-same-version