Haskell package guidelines
From ArchWiki
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.
Contents |
Community
The main resources for the Arch/Haskell community to interact and discuss are:
- #arch-haskell irc channel @ freenode.org
- Good for quick discussion and planning
- arch-haskell@haskell.org mailing list
- Broader announcements, and automated updates
- Arch Haskell Weekly News
- A blog announcing our progress to the outside world.
Haskell Packages
The core Haskell tools are available in the core system (extra):
[Extra]
Currently just the compilers
[Community]
The start of the Haskell platform, a set of core libraries for building more things.
AUR
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.
Guidelines
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:
Or:
- 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 pkgname=haskell-cc-delcont pkgrel=1 pkgver=0.2 pkgdesc="Delimited continuations and dynamically scoped variables" url="http://hackage.haskell.org/package/CC-delcont" license=('custom:OtherLicense') arch=('i686' 'x86_64') makedepends=() depends=('ghc' 'haskell-cabal') options=('strip') source=(http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz) install=haskell-cc-delcont.install md5sums=('e52149fca9bf76330a7c159917152790') 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:
#!/bin/sh 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 pwd=`pwd` 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-2.1.0.0 cgi-3001.1.5.1 network-2.1.0.0 regex-base-0.72.0.1 Cabal-1.2.3.0 containers-0.1.0.1 old-locale-1.0.0.0 regex-compat-0.71.0.1 GLUT-2.1.1.1 directory-1.0.0.0 old-time-1.0.0.0 regex-posix-0.72.0.2 HUnit-1.2.0.0 fgl-5.4.1.1 packedstring-0.1.0.0 stm-2.1.1.0 OpenAL-1.3.1.1 filepath-1.1.0.0 parallel-1.0.0.0 template-haskell-2.2.0.0 OpenGL-2.2.1.1 haskell-src-1.0.1.1 parsec-2.1.0.0 time-1.1.2.0 QuickCheck-1.1.0.0 haskell98-1.0.1.0 pretty-1.0.0.0 unix-2.3.0.0 array-0.1.0.0 hpc-0.5.0.0 process-1.0.0.0 xhtml-3000.0.2.1 base-3.0.1.0 html-1.0.1.1 random-1.0.0.0 bytestring-0.9.0.1 mtl-1.1.0.0 readline-1.0.1.0
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
AUR
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.
#!/bin/sh 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 continue fi 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/ else echo "Failed" fi cd $tmpdir done echo `ls $finaldir/*pkg* | wc -l` "build packages in $finaldir" echo "Now: scp -r $finaldir/* code.haskell.org:/srv/code/arch/$MACHTYPE/"