# Copyright 1999-2025 entoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# ebuild generated by hackport 0.9.0.0.9999

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

DESCRIPTION="High performance web server on WAI/warp"
HOMEPAGE="https://kazu-yamamoto.github.io/mighttpd2/"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="dhall quic tls"

RDEPEND="dev-haskell/async:=[profile?]
	acct-group/mighttpd2
	acct-user/mighttpd2
	dev-haskell/auto-update:=[profile?]
	dev-haskell/byteorder:=[profile?]
	dev-haskell/case-insensitive:=[profile?]
	>=dev-haskell/conduit-1.1:=[profile?]
	dev-haskell/conduit-extra:=[profile?]
	>=dev-haskell/http-client-0.5:=[profile?]
	dev-haskell/http-date:=[profile?]
	dev-haskell/http-types:=[profile?]
	dev-haskell/network:=[profile?]
	dev-haskell/old-locale:=[profile?]
	>=dev-haskell/parsec-3:=[profile?]
	dev-haskell/resourcet:=[profile?]
	dev-haskell/split:=[profile?]
	dev-haskell/streaming-commons:=[profile?]
	dev-haskell/text:=[profile?]
	dev-haskell/time-manager:=[profile?]
	dev-haskell/unix-time:=[profile?]
	dev-haskell/unordered-containers:=[profile?]
	>=dev-haskell/wai-3.2:=[profile?] <dev-haskell/wai-3.3:=[profile?]
	>=dev-haskell/wai-app-file-cgi-3.1.9:=[profile?] <dev-haskell/wai-app-file-cgi-3.2:=[profile?]
	>=dev-haskell/wai-logger-2.3.0:=[profile?]
	>=dev-haskell/warp-3.4:=[profile?] <dev-haskell/warp-3.5:=[profile?]
	>=dev-lang/ghc-9.0.2:=
	dhall? ( dev-lang/dhall:=[profile?] )
	quic? ( dev-haskell/base16-bytestring:=[profile?]
		>=dev-haskell/quic-0.2:=[profile?] <dev-haskell/quic-0.3:=[profile?]
		>=dev-haskell/warp-quic-0.0.1:=[profile?] )
	tls? ( dev-haskell/tls:=[profile?]
		>=dev-haskell/tls-session-manager-0.0.5:=[profile?]
		>=dev-haskell/warp-tls-3.2.12:=[profile?] <dev-haskell/warp-tls-3.5:=[profile?] )
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.4.1.0
	test? ( >=dev-haskell/hspec-1.3 )
"

src_configure() {
	haskell-cabal_src_configure \
		$(cabal_flag dhall dhall) \
		$(cabal_flag quic quic) \
		$(cabal_flag tls tls)
}

src_install() {
	haskell-cabal_src_install

	mkdir -p "${ED}"/etc/mighttpd2

	cp "${FILESDIR}"/mighttpd2.conf "${ED}"/etc/mighttpd2/mighttpd2.conf || die
	cp "${FILESDIR}"/mighttpd2.route "${ED}"/etc/mighttpd2/mighttpd2.route || die

	newinitd "${FILESDIR}"/mighttpd2.initd mighttpd2
	keepdir /var/log/mighttpd2
	fperms 0700 /var/log/mighttpd2
	fowners ${PN}:${PN} /var/log/mighttpd2

	systemd_dounit "${FILESDIR}"/mighttpd2.service
	systemd_newtmpfilesd "${FILESDIR}"/${PN}-tmpfiles.d.conf ${PN}.conf
}