Haskell package guidelines

From ArchWiki
(Redirected from Haskell Package Guidelines)
Jump to navigation Jump to search

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Please help improve this article by creating reasonable package creation guidelines for Haskell packages. (Discuss in Talk:Haskell package guidelines#)
Arch package guidelines

32-bitCLRCMakeCrossDKMSEclipseElectronFontFree PascalGNOMEGoHaskellJavaKDEKernelLispMesonMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustVCSWebWine

This document aims to cover standards and guidelines for producing good Haskell packages on Arch.

Until this document is written, contact User:Felixonmars

Package naming

For Haskell libraries, use haskell-libraryname usually the same name as on hackage.

Note: The package name should be entirely lowercase.

Architecture

See PKGBUILD#arch.

Every Haskell library or program is architecture-dependent.

Source

The preferred source of a Haskell program or library is from hackage. PKGBUILD#source source=() array should use the following URL template:

https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz

Note that a custom _hkgname variable is used instead of pkgname since Haskell packages are generally prefixed with haskell-. This variable can generically be defined as follows:

_hkgname=stm-delay

Rebuild order

When a Haskell library changes its build flags or is updated all dependent packages need to be rebuild.

PKGBUILD library example

Packaging a Haskell library is different from packaging a Haskell program, the libraries packaged in Arch Linux are meant to be used by packaged Haskell programs.

PKGBUILD
# Maintainer: Your Name <youremail@domain.com>
_hkgname=stm-delay
pkgname=haskell-stm-delay
pkgver=
pkgrel=1
license=()
arch=('x86_64')
url="https://hackage.haskell.org/package/$_hkgname"
depends=(ghc-libs)
makedepends=(ghc)
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha256sums=()

build() {
  cd "$_hkgname-$pkgver"

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir="/usr/share/doc/$pkgname" --enable-tests \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie'

  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd "$_hkgname-$pkgver"
  runhaskell Setup test
}

package() {
  cd "$_hkgname-$pkgver"

  install -D -m744 register.sh "$pkgdir/usr/share/haskell/register/$pkgname.sh"
  install -D -m744 unregister.sh "$pkgdir/usr/share/haskell/unregister/$pkgname.sh"
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm -f "${pkgdir}/usr/share/doc/${pkgname}/LICENSE"
}