gnucash: add updateScript

This commit is contained in:
Yongun Seong 2023-12-19 19:38:33 +09:00
parent 886c9aee6c
commit 5e2080f832
No known key found for this signature in database
2 changed files with 26 additions and 0 deletions

View File

@ -138,6 +138,8 @@ stdenv.mkDerivation rec {
--prefix PERL5LIB : "${with perlPackages; makeFullPerlPath [ JSONParse FinanceQuote ]}"
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
homepage = "https://www.gnucash.org/";
description = "Free software for double entry accounting";

View File

@ -0,0 +1,24 @@
#!/usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p curl jq nix-prefetch-github
set -euo pipefail
latest_version=$(curl -s https://api.github.com/repos/Gnucash/gnucash/releases/latest | jq -r '.tag_name')
if [[ "$latest_version" = "$UPDATE_NIX_OLD_VERSION" ]]; then
echo "already up to date"
exit 0
fi
old_src_hash=$(nix-instantiate --eval -A gnucash.src.outputHash | tr -d '"')
old_src_doc_hash=$(nix-instantiate --eval -A gnucash.docs.src.outputHash | tr -d '"')
src_hash=$(nix-prefetch-url "https://github.com/Gnucash/gnucash/releases/download/$latest_version/gnucash-$latest_version.tar.bz2")
src_hash=$(nix-hash --to-sri --type sha256 "$src_hash")
src_doc_hash=$(nix-prefetch-github Gnucash gnucash-docs --rev "$latest_version" | jq -r .hash)
src_doc_hash=$(nix-hash --to-sri --type sha256 "$src_doc_hash")
cd "$(dirname "${BASH_SOURCE[0]}")"
sed -i default.nix -e "s|$old_src_hash|$src_hash|"
sed -i default.nix -e "s|$old_src_doc_hash|$src_doc_hash|"
sed -i default.nix -e "/ version =/s|\"${UPDATE_NIX_OLD_VERSION}\"|\"${latest_version}\"|"