haskell-cabal.eclass

Name

haskell-cabal.eclass -- for packages that make use of the Haskell Common Architecture for Building Applications and Libraries (cabal)

Description

Basic instructions:

Before inheriting the eclass, set CABAL_FEATURES to reflect the tools and features that the package makes use of.

Currently supported features:

haddock

for documentation generation

hscolour

generation of colourised sources

hoogle

generation of documentation search index

profile

if package supports to build profiling-enabled libraries

bootstrap

only used for the cabal package itself

lib

the package installs libraries

nocabaldep

don't add dependency on cabal. only used for packages that must not pull the dependency on cabal, but still use this eclass (e.g. haskell-updater).

ghcdeps

constraint dependency on package to ghc onces only used for packages that use libghc internally and must not pull upper versions

test-suite

add support for cabal test-suites (introduced in Cabal-1.8)

rebuild-after-doc-workaround

enable doctest test failue workaround.

Symptom: when ./setup haddock is run in a build-type: Custom package it might cause cause the test-suite to fail with errors like:

<command line>: cannot satisfy -package-id singletons-2.7-3Z7pnljD8tU1NrslJodXmr

Workaround re-reginsters the package to avoid the failure (and rebuilds changes).

FEATURE can be removed once https://github.com/haskell/cabal/issues/7213 is fixed.

Supported EAPIs

6 7 8

Exported Phases

  • pkg_setup

  • pkg_postrm

  • pkg_postinst

  • src_compile

  • src_test

  • src_install

  • src_prepare

  • src_configure

Functions

cabal_flag

ebuild.sh:use_enable() taken as base

Usage examples:

CABAL_CONFIGURE_FLAGS=$(cabal_flag gui)

leads to --flags=gui or --flags=-gui (useflag gui)

CABAL_CONFIGURE_FLAGS=$(cabal_flag gtk gui)

also leads to --flags=gui or --flags=-gui (useflag gtk)

cabal_chdeps

Allows easier patching of ${CABAL_FILE} (${S}/${PN}.cabal by default) depends

Accepts argument list as pairs of substitutions: <from-string> <to-string>...

Dies on error.

Usage examples:

src_prepare() {
   cabal_chdeps \
       'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7' \
       'containers ==0.4.*' 'containers >= 0.4 && < 0.6'
}

or

src_prepare() {
   CABAL_FILE=${S}/${CABAL_PN}.cabal cabal_chdeps \
       'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7'
   CABAL_FILE=${S}/${CABAL_PN}-tools.cabal cabal_chdeps \
       'base == 3.*' 'base >= 4.2 && < 4.7'
}
cabal-constraint

Allowes to set contraint to the libraries that are used by specified package

replace-hcflags <old> <new>

Replace the <old> flag with <new> in HCFLAGS. Accepts shell globs for <old>. The implementation is picked from flag-o-matic.eclass:replace-flags()

Variables

CABAL_EXTRA_CONFIGURE_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup configure.

Example /etc/portage/make.conf

CABAL_EXTRA_CONFIGURE_FLAGS="--enable-shared --enable-executable-dynamic"
CABAL_EXTRA_BUILD_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup build.

Example /etc/portage/make.conf:

CABAL_EXTRA_BUILD_FLAGS="-v"
GHC_BOOTSTRAP_FLAGS (USER VARIABLE)

User-specified additional parameters for ghc when building only setup binary bootstrap.

Example /etc/portage/make.conf:

# to make linking 'setup' faster.
GHC_BOOTSTRAP_FLAGS="-dynamic"
CABAL_EXTRA_HADDOCK_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup haddock.

Example /etc/portage/make.conf:

CABAL_EXTRA_HADDOCK_FLAGS="--haddock-options=--latex --haddock-options=--pretty-html"
CABAL_EXTRA_HOOGLE_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup haddock --hoogle.

Example /etc/portage/make.conf:

CABAL_EXTRA_HOOGLE_FLAGS="--haddock-options=--show-all"
CABAL_EXTRA_HSCOLOUR_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup hscolour.

Example /etc/portage/make.conf:

CABAL_EXTRA_HSCOLOUR_FLAGS="--executables --tests"
CABAL_EXTRA_TEST_FLAGS (USER VARIABLE)

User-specified additional parameters passed to setup test.

Example /etc/portage/make.conf:

CABAL_EXTRA_TEST_FLAGS="-v3 --show-details=streaming"
CABAL_DEBUG_LOOSENING

Show debug output for cabal_chdeps function if set. Needs working diff.

CABAL_REPORT_OTHER_BROKEN_PACKAGES ?= yes

Show other broken packages if cabal configure fails. It should be normally enabled unless you know you are about to try to compile a lot of broken packages. Default value: yes Set to anything else to disable.

CABAL_HACKAGE_REVISION ?= 0 (SET BEFORE INHERIT)

Set the upstream revision number from Hackage. This will automatically add the upstream cabal revision to SRC_URI and apply it in src_prepare.

CABAL_PN ?= ${PN} (SET BEFORE INHERIT)

Set the name of the package as it is recorded in the Hackage database. This is mostly used when packages use CamelCase names upstream, but we want them to be lowercase in portage.

CABAL_PV ?= ${PV} (SET BEFORE INHERIT)

Set the version of the package as it is recorded in the Hackage database. This can be useful if we use a different versioning scheme in Portage than the one from upstream

CABAL_P = "${CABAL_PN}-${CABAL_PV}" (GENERATED BY ECLASS)

The combined ${CABAL_PN} and ${CABAL_PV} variables, analogous to ${P}

CABAL_FILE ?= "${S}/${CABAL_PN}.cabal"

The location of the .cabal file for the Haskell package. This defaults to ${S}/${CABAL_PN}.cabal.

CABAL_DISTFILE (GENERATED BY ECLASS)

The name of the .cabal file downloaded from Hackage. This filename does not include ${DISTDIR}

CABAL_CHDEPS

Specifies changes to be made to the .cabal file. Uses the cabal_chdeps function internally and shares the same syntax.

CABAL_CHDEPS=(
   'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7'
   'containers ==0.4.*' 'containers >= 0.4 && < 0.6'
)
CABAL_LIVE_VERSION (SET BEFORE INHERIT)

Set this to any value to prevent SRC_URI from being set automatically.

GHC_BOOTSTRAP_PACKAGES

Extra packages that need to be exposed when compiling Setup.hs

GHC_BOOTSTRAP_PACKAGES=(
    cabal-doctest
)

Authors

Original author: Andres Loeh <kosmikus@gentoo.org>

Original author: Duncan Coutts <dcoutts@gentoo.org>

Maintainers

Haskell herd <haskell@gentoo.org>

Reporting Bugs

Please report bugs via https://bugs.gentoo.org/