# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# ebuild generated by hackport 0.8.4.0.9999
#hackport: flags: -monolithic,+network-uri,-debug-tracetree,-debug-expensive-assertions

CABAL_HACKAGE_REVISION=3

CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
inherit haskell-cabal

RESTRICT="test" # Test suite has a lot of failures, probably needs some expected environment

DESCRIPTION="The command-line interface for Cabal and Hackage"
HOMEPAGE="https://www.haskell.org/cabal/"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="+lukko +native-dns"

PATCHES=(
	"${FILESDIR}/${PN}-3.8.1.0-fix-unit-test-imports.patch"
	"${FILESDIR}/${PN}-3.8.1.0-cabal-update-no-dist-newstyle.patch"
)

RDEPEND="
	>=dev-haskell/async-2.0:=[profile?] <dev-haskell/async-2.3:=[profile?]
	>=dev-haskell/base16-bytestring-0.1.1:=[profile?] <dev-haskell/base16-bytestring-1.1.0.0:=[profile?]
	>=dev-haskell/cabal-3.8:=[profile?] <dev-haskell/cabal-3.9:=[profile?]
	>=dev-haskell/cabal-install-solver-3.8:=[profile?] <dev-haskell/cabal-install-solver-3.9:=[profile?]
	>=dev-haskell/cabal-syntax-3.8:=[profile?] <dev-haskell/cabal-syntax-3.9:=[profile?]
	>=dev-haskell/cryptohash-sha256-0.11:=[profile?] <dev-haskell/cryptohash-sha256-0.12:=[profile?]
	>=dev-haskell/echo-0.1.3:=[profile?] <dev-haskell/echo-0.2:=[profile?]
	>=dev-haskell/edit-distance-0.2.2:=[profile?] <dev-haskell/edit-distance-0.3:=[profile?]
	>=dev-haskell/hackage-security-0.6.2.0:=[profile?] <dev-haskell/hackage-security-0.7:=[profile?]
	>=dev-haskell/hashable-1.0:=[profile?] <dev-haskell/hashable-1.5:=[profile?]
	>=dev-haskell/http-4000.1.5:=[profile?] <dev-haskell/http-4000.5:=[profile?]
	>=dev-haskell/network-uri-2.6.0.2:=[profile?] <dev-haskell/network-uri-2.7:=[profile?]
	>=dev-haskell/parsec-3.1.13.0:=[profile?] <dev-haskell/parsec-3.2:=[profile?]
	>=dev-haskell/random-1.2:=[profile?] <dev-haskell/random-1.3:=[profile?]
	>=dev-haskell/regex-base-0.94.0.0:=[profile?] <dev-haskell/regex-base-0.95:=[profile?]
	>=dev-haskell/regex-posix-0.96.0.0:=[profile?] <dev-haskell/regex-posix-0.97:=[profile?]
	>=dev-haskell/safe-exceptions-0.1.7.0:=[profile?] <dev-haskell/safe-exceptions-0.2:=[profile?]
	>=dev-haskell/tar-0.5.0.3:=[profile?] <dev-haskell/tar-0.6:=[profile?]
	>=dev-haskell/zlib-0.5.3:=[profile?] <dev-haskell/zlib-0.7:=[profile?]
	>=dev-lang/ghc-8.10.6:=
	|| (
		( >=dev-haskell/text-1.2.3 <dev-haskell/text-1.3 )
		( >=dev-haskell/text-2.0 <dev-haskell/text-2.1 )
	)
	dev-haskell/text:=[profile?]
	lukko? (
		>=dev-haskell/lukko-0.1:=[profile?] <dev-haskell/lukko-0.2:=[profile?]
	)
	native-dns? (
		>=dev-haskell/resolv-0.1.1:=[profile?] <dev-haskell/resolv-0.2:=[profile?]
	)
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.2.1.0
	test? (
		dev-haskell/cabal-described
		dev-haskell/cabal-quickcheck
		dev-haskell/cabal-tree-diff
		>=dev-haskell/network-uri-2.6.2.0 <dev-haskell/network-uri-2.7
		>=dev-haskell/pretty-show-1.6.15
		>=dev-haskell/quickcheck-2.14 <dev-haskell/quickcheck-2.15
		dev-haskell/tagged
		>=dev-haskell/tasty-1.2.3 <dev-haskell/tasty-1.5
		dev-haskell/tasty-expected-failure
		>=dev-haskell/tasty-golden-2.3.1.1 <dev-haskell/tasty-golden-2.4
		>=dev-haskell/tasty-hunit-0.10
		dev-haskell/tasty-quickcheck
		dev-haskell/tree-diff
	)
"

src_configure() {
	haskell-cabal_src_configure \
		--flag=-debug-expensive-assertions \
		--flag=-debug-tracetree \
		$(cabal_flag lukko lukko) \
		--flag=-monolithic \
		$(cabal_flag native-dns native-dns) \
		--flag=network-uri
}