Difference between revisions of "Haskell package guidelines"

From ArchWiki
Jump to navigation Jump to search
Line 12: Line 12:
== Community ==
== Community ==
The main resources for the [[ArchHaskell]] community to interact and discuss are:
All the details on the [[ArchHaskell]] group is available on its own page.
* [http://www.gogloom.com/FreeNode/arch-haskell <nowiki>#arch-haskell</nowiki>] irc channel @ freenode.org
** Good for quick discussion and planning
* [http://haskell.org/mailman/listinfo/arch-haskell arch-haskell@haskell.org] mailing list
** Broader announcements, and automated updates
* [https://github.com/archhaskell ArchHaskell group] on github
** Repositories for tools as well as the source for the binary packages (HABS).
== Haskell Packages ==
== Haskell Packages ==

Revision as of 22:09, 12 February 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Haskell on Arch Linux

Haskell is well supported on Arch Linux, with GHC and other key tools available via pacman, a growing number of packages made available by the ArchHaskell group, and a large part of hackage.haskell.org library database available via AUR.

The community around Haskell on Arch is active and well organized but your help is always welcome.


All the details on the ArchHaskell group is available on its own page.

Haskell Packages

The core Haskell tools are available in the core system (extra):


Our policy is for [extra] to provide the Haskell platform, and popular Haskell applications.


The packages maintained by the ArchHaskell group can be accessed by adding the following entry to pacman.conf:

Server = http://andromeda.kiwilight.com/$repo/$arch


A huge number (almost 2000) packages built from http://hackage.haskell.org

These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:

   sudo paktahn -S haskell-csv

Anything not found here can be installed via cabal-install direct from Hackage.


In almost all cases cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:

  • Add the [haskell] repository to pacman.conf and use pacman do install the latest release.
  • Download and build the source from AUR, either manually or using one of the many AUR Helpers.
  • Install directly from Hackage using "cabal install cabal2arch".

cabal2arch: an example

This example illustrates how to create a new package with cabal2arch. We'll make a new package for the delimited continuations library, CC-delcont:

First, set the name and email address to be used in the generated PKGBUILD:

export ARCH_HASKELL='My Name <my.name@domain.org>'

Second, find the hackage page for CC-delcont, then identify the link to the .cabal file. Use this link as an argument to cabal2arch:

% cd /tmp
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/
Using /tmp/tmp.x9SEhTJ8N9/pandoc.cabal
Feeding the PKGBUILD to `makepkg -g`...
==> Retrieving Sources...
  -> Downloading pandoc-
--2011-01-30 22:12:18--  http://hackage.haskell.org/packages/archive/pandoc/
Resolving hackage.haskell.org...
Connecting to hackage.haskell.org||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 355477 (347K) [application/x-tar]
Saving to: `pandoc-'

     0K .......... .......... .......... .......... .......... 14% 20.3K 15s
    50K .......... .......... .......... .......... .......... 28% 40.3K 9s
   100K .......... .......... .......... .......... .......... 43% 53.0K 6s
   150K .......... .......... .......... .......... .......... 57% 58.2K 4s
   200K .......... .......... .......... .......... .......... 72% 57.7K 2s
   250K .......... .......... .......... .......... .......... 86% 67.1K 1s
   300K .......... .......... .......... .......... .......   100% 76.4K=7.7s

2011-01-30 22:12:27 (44.9 KB/s) - `pandoc-' saved [355477/355477]

==> Generating checksums for source files...

Checking what was created:

% ls

You can now inspect the PKGBUILD and install script for the library:

# Maintainer: My Name <my.name@domain.org>
pkgdesc="Conversion between markup formats"
arch=('i686' 'x86_64')
depends=('ghc' 'haskell-http=4000.0.9' 'haskell-bytestring=' 'haskell-containers=' 'haskell-directory=' 'haskell-extensible-exceptions=' 'haskell-filepath=' 'haskell-mtl>=1.1' 'haskell-network=' 'haskell-old-time=' 'haskell-parsec=' 'haskell-pretty=' 'haskell-process=' 'haskell-random=' 'haskell-syb=' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')
build() {
    cd ${srcdir}/${_hkgname}-${pkgver}
    runhaskell Setup configure -O --enable-split-objs --enable-shared \
       --prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid
    runhaskell Setup build
    runhaskell Setup haddock
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
package() {
    cd ${srcdir}/${_hkgname}-${pkgver}
    install -D -m744 register.sh   ${pkgdir}/usr/share/haskell/${pkgname}/register.sh
    install    -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh
    install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries
    ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}
    runhaskell Setup copy --destdir=${pkgdir}

It follows the conventions for Haskell packages:

  • Libraries are prefixed with "haskell-"
  • All libraries that the package depend on are listed (libraries shipped with ghc are dealt with by having the ghc package provide them)
  • It uses cabal to generate a post-install register/unregister script, with a standard name.
  • We use haddock to build the documentation.

All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.

Guidelines for Libraries

In general, each .cabal file should map to one PKGBUILD. The following conventions hold:

  • libraries have their cabal names prefixed with "haskell-"
  • all libraries have a dependency on 'ghc'
  • all libraries that are depended on must be listed in the depends-array in the PKGBUILD
  • be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the 'gtk2hs' package, not , e.g. "haskell-cairo"

Registering Haskell libraries is done via a register hook, see above.

Guidelines for Programs

  • Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install
  • Be careful about dynamically linked runtime dependencies on C. For example, all GHC-produced binaries have a runtime dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.
  • Use executable stripping, --enable-executable-stripping. cabal2arch will do this automatically.

Automatic local building of Hackage Packages with cabal2arch using Bauerbill

Although there are a number of haskell packages on AUR, there will always be outdated packages on AUR. If this happens and you want to create a fully updated package you would normally use cabal2arch. This however can become painful/time consuming if you have numerous packages with different dependencies (some of which may/may not be updated). Instead you can automatic this process by using Bauerbill which has the --hackage flag, allowing you to create AUR packages from Hackage locally. Below is an example of some common commands

   bauerbill -S --hackage [pkgs] : build [pkgs] directly from Hackage*
   bauerbill -Si --hackage [pkgs] : look up information about [pkgs]
   bauerbill -Ss --hackage [args] : search for [args]
   bauerbill -Qu --hackage : list upgradable Hackage packages

Syncing packages with the --hackage flag will interactively download all dependencies of the package from Hackage, convert them using cabal2arch and then build/install them (while checking dependencies). You can combine this with the --aur flag to give precedence to Hackage packages that are on AUR