# Contributor: Dhruvin Gandhi <contact@dhru.vin>
# Maintainer: Dhruvin Gandhi <contact@dhru.vin>
pkgname=hledger-interest
pkgver=1.6.6
pkgrel=4
_llvmver=15
pkgdesc="hledger addon to compute interest for a given account"
url="https://github.com/peti/hledger-interest"
arch="aarch64 x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="ghc cabal ncurses-dev zlib-dev"
source="https://hackage.haskell.org/package/hledger-interest-$pkgver/hledger-interest-$pkgver.tar.gz
	ghc-9.8.patch
	cabal.project.freeze"
options="net !check" # no tests

export CABAL_DIR="$srcdir"/cabal
export PATH="/usr/lib/llvm$_llvmver/bin:$PATH"

cabal_update() {
	cd $builddir
	cabal v2-update
	(
		cd "$builddir"
		cabal v2-freeze --shadow-installed-packages
		mv cabal.project.freeze "$startdir/"
	)
}

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

package() {
	install -Dm755 "$(cabal list-bin hledger-interest)" "$pkgdir"/usr/bin/hledger-interest
}

sha512sums="
77ddb8e930e4f2e7f9d03455872afd45826c53aa84fe3a17204b17c2afa283e3a834217ea28eedaddc9822ffee0857afbc2f9ab13327df56c347108d8f909c2f  hledger-interest-1.6.6.tar.gz
37fe24bb80e58fbdddd527e320714e2db02c2f156d9328c63d0e0b4c5a1753b07f2d6ded43039db8764fb9b9a3e61f43e5f1ed8d79f8b8d91050fec02677bdcf  ghc-9.8.patch
69eb598e4d359c1ca217d1f21325a52cdb14eae54b968db4ed9f4c1278f9779ffa66ca9b8f68426111afc4857b2982acb3706f3406d6bc932c7579f17566d30a  cabal.project.freeze
"
