# Contributor: Dhruvin Gandhi <contact@dhru.vin>
# Maintainer: Dhruvin Gandhi <contact@dhru.vin>
pkgname=hledger-iadd
pkgver=1.3.21
pkgrel=1
pkgdesc="A terminal UI as drop-in replacement for hledger add"
url="https://github.com/hpdeifel/hledger-iadd#readme"
arch="aarch64 x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="
	cabal
	ghc
	libffi-dev
	ncurses-dev
	zlib-dev
	"
_llvmver=15
options="net"
source="https://hackage.haskell.org/package/hledger-iadd-$pkgver/hledger-iadd-$pkgver.tar.gz
	cabal.project.freeze"

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

cabal_update() {
	cd "$builddir"
	cabal v2-update
	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
}

check() {
	cabal test
}

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

sha512sums="
26bf43b3c0cfbf9ddbaf1828247a5345efbb8d8d05773adaecec30d54f2122bdc005b745614da7bb58822a7cbb9da1305b70bac890d087dc69038b95eb4bf1d6  hledger-iadd-1.3.21.tar.gz
53342054ee977897698125a61b8e25af1799fa262f664926a156da926fc32d98d1a4d447e4fdc6ac7f90f237782a4b8f0d3a9ac76966274cf581877278f732e9  cabal.project.freeze
"
