Haskell package guidelines

From ArchWiki
Revision as of 18:50, 18 October 2009 by Gog (Talk | contribs)

Jump to: navigation, search

Haskell on Arch Linux

Haskell is well supported on Arch Linux, with GHC and other key tools available via pacman, and 87% percent of hackage.haskell.org library database available via AUR.

The status of all Haskell packages in Arch Linux

The community around Haskell on Arch is also active and well organized.


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):


Currently just the compilers


The start of the Haskell platform, a set of core libraries for building more things.


A huge number (almost 1000) 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:

   yaourt --aur -S --noconfirm cabal2arch

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

Direction and strategy

The strategy for Haskell on Arch Linux is to support the Haskell platform suite in [community].

The "out-of-the-box" haskell support is lacking at the moment in Arch, with only a small number of libraries and applications supported in extras or community (see below). We have a lot more in AUR though. Certainly not enough for a comfortable development environment of of the box. And this despite there being hundreds of useful libraries and tools on hackage.haskell.org

So the next step is to migrate the Haskell Platform into community.

Other key libraries can be determined based on use and votes.


In almost all cases cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool.

We strongly recommend its use, as it creates very good packages, that are consistent with the other 1000 AUR Haskell packages.

Development version:


  • cabal install cabal2arch

Most things on http://hackage.haskell.org that are packageable, are already in AUR.

If not, download and build cabal2arch, as below, and use that to create the package. This will ensure it follows standard naming, dependency and installation conventions. Drop by #arch-haskell to let us know what is going on.

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.

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/"