Haskell package guidelines

From ArchWiki
Revision as of 21:56, 30 January 2011 by Magus (talk | contribs)
Jump to navigation Jump to search

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.


The main resources for the Arch/Haskell community to interact and discuss are:

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, 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/CC-delcont/0.2/CC-delcont.cabal
Using /tmp/tmp.Ig0H8jCOyO/CC-delcont.cabal
Fetching http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz
Created /tmp/haskell-cc-delcont.tar.gz

Checking what was created:

$ ls
haskell-cc-delcont  haskell-cc-delcont.tar.gz

The .tar.gz is a zipped PKGBUILD ready to upload to AUR. You can now inspect the PKGBUILD and install script for the library:

   # Contributor: Arch Haskell Team <arch-haskell@haskell.org>
   # Package generated by cabal2arch 0.6.1
   pkgdesc="Delimited continuations and dynamically scoped variables"
   arch=('i686' 'x86_64')
   depends=('ghc' 'haskell-cabal')
   build() {
       cd ${srcdir}/CC-delcont-0.2
       runhaskell Setup configure --prefix=/usr --docdir=/usr/share/doc/${pkgname} || return 1
       runhaskell Setup build                   || return 1
       runhaskell Setup haddock || return 1
       runhaskell Setup register   --gen-script || return 1
       runhaskell Setup unregister --gen-script || return 1
       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/libraries
       ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/libraries/CC-delcont
       runhaskell Setup copy --destdir=${pkgdir} || return 1
       install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE || return 1
       rm -f ${pkgdir}/usr/share/doc/${pkgname}/LICENSE

It follows the conventions for Haskell packages:

  • Maintainer is by default the Arch Haskell team.
  • Libraries are prefixed with "haskell-"
  • "core" and "extra" Haskell libraries are not included as explicit dependencies, since ghc provides them
  • It uses cabal to generate a post-install register/unregister script, with a standard name.
  • We use haddock to build the documentation.
  • Profiling versions of the library aren't currently installed (TODO)

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

Inspect the bundle, and confirm you can build and install it:

   $ makepkg -s
   $ makepkg -i

And we're ready to go. Now your .tar.gz is ready to upload to AUR.


See the discussion on the use of "provides" here.

Uploading the the Haskell repository

This section is out of date

The following (ad hoc) script is currently used to upload packages after running cabal2arch to the respository, and keep it in sync:

set -e
makepkg -i
scp *-x86_64.pkg.tar.gz code.haskell.org:/srv/code/arch/x86_64/
repo-add /home/dons/haskell.db.tar.gz *.pkg.tar.gz
rm -rf *.tar.gz pkg src
dir=`basename $pwd`
cd ..
scp -r $dir code.haskell.org:/srv/code/arch/x86_64/
scp $HOME/haskell.db.tar.gz code.haskell.org:/srv/code/arch/x86_64/

This is to be used by those with arch-haskell repository write permissions.

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 haskell dependencies are statically linked, so can go in the makedepends field.
  • all libraries have a dependency on 'ghc'
  • libraries don't need to have explicit dependencies on core Haskell packages -- these come in the 'ghc' package. (e.g. array, base, containers, random, process etc).
  • be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the 'gtk2hs' package, not , e.g. "haskell-cairo"
  • we want to resolve dependencies with a fixed constraint to base>=3.0
  • be careful about dependencies on the libraries provided by the basic 'ghc' package, which include:
ALUT-        cgi-3001.1.5.1       network-       regex-base-
Cabal-       containers-   old-locale-    regex-compat-
GLUT-        directory-    old-time-      regex-posix-
HUnit-       fgl-          packedstring-  stm-
OpenAL-      filepath-     parallel-      template-haskell-
OpenGL-      haskell-src-  parsec-        time-
QuickCheck-  haskell98-    pretty-        unix-
array-       hpc-          process-       xhtml-3000.0.2.1
base-        html-         random-
bytestring-  mtl-          readline-

These libraries don't need explicit dependencies to be set. cabal2arch solves all these constraints for us.

Registering Haskell libraries is done via a register hook:

build() {
   cd ${srcdir}/cabal2arch-0.1
   runhaskell Setup configure --prefix=/usr || return 1
   runhaskell Setup build                   || return 1
   -- generate register scripts
   runhaskell Setup register   --gen-script || return 1
   runhaskell Setup unregister --gen-script || return 1
   install -D -m744 register.sh    ${pkgdir}/usr/share/haskell/$pkgname/register.sh
   install    -m744 unregister.sh ${pkgdir}/usr/share/haskell/$pkgname/unregister.sh
   runhaskell Setup copy --destdir=${pkgdir} || return 1
   -- usual Haskell BSD3 license isnt' official
   install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE || return 1
  • Examples:
haskell-zlib, haskell-mersenne-random

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.

Haskell on Arch: current state

* http://www.galois.com/~dons/arch-haskell-status.html


There's another > 550 Haskell packages in AUR.

Building all of Hackage

The following simple script, with cabal-install and cabal2arch installed, will do a simple run over all the Haskell packages on haskell.org, creating arch packages for them. Before you start it is worthwhile removing all haskell packages, and reinstalling them. And then editing your unpacked haskell package directory to remove base libraries -- you probably don't want to install them.

   cabal update
   tmpdir=`mktemp -d`
   finaldir=`mktemp -d`
   cd $tmpdir
   tar xzf $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz
   for dir in * ; do 
        if [ ! -d $dir ] ; then
        cd $dir
        lib=`ls --color=never -1 | tail -1`
        echo "************** Building package for $dir-$lib"
        cd $lib
        cabal2arch *.cabal > $dir.log 2>&1
        cd `find . -type d -a ! -name '.'`
        if makepkg -sm > ../$dir.log 2>&1 ; then
            echo "OK: " $dir-$lib
            cp *.pkg.tar.gz $finaldir/
            sudo pacman -A *.pkg.tar.gz
            rm *.pkg.tar.gz
            rm -rf pkg src *.tar.gz
            cd ..
            cp -R `find . -type d -a ! -name '.'` $finaldir/
            cp *.tar.gz $finaldir/
            echo "Failed"
        cd $tmpdir
   echo `ls $finaldir/*pkg* | wc -l` "build packages in $finaldir"
   echo "Now: scp -r $finaldir/* code.haskell.org:/srv/code/arch/$MACHTYPE/"

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