Difference between revisions of "Haskell package guidelines"

From ArchWiki
Jump to: navigation, search
(rewrite the options for using haskell on arch linux)
(Haskell Packages: A little warning about haskell-xmonad vs. xmonad)
(8 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
{{Package Guidelines}}
 
{{Package Guidelines}}
  
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].
+
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux.
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.
+
GHC and a few core packages are available in the [[Official Repositories|official repositories]].
 +
For more serious Haskellers, the [[ArchHaskell]] community project provides many packages from [http://hackage.haskell.org Hackage], and the number is growing.
  
The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!
+
See the [[ArchHaskell]] community page for contact details and ways to help.
 
+
== Community ==
+
All the details on the [[ArchHaskell]] group is available on its own page.
+
  
 
== Haskell Packages ==
 
== Haskell Packages ==
 
To use Haskell on Arch Linux, you have two mutually exclusive options:
 
To use Haskell on Arch Linux, you have two mutually exclusive options:
 
# Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 extra] and [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 community] repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.
 
# Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 extra] and [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 community] repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.
# Use the Arch-Haskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them.
+
# Use the ArchHaskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them. A note for [[xmonad]] users: if you switch to this option, you need to install the '''haskell-xmonad''' package instead of {{Pkg|xmonad}} (which is in the official community repo and has different dependencies).
  
=== [haskell] ===
+
=== [haskell-core] ===
The [haskell] repository is the main repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:
+
The [haskell-core] repository is the base repository of packages maintained by the ArchHaskell team.
 +
[haskell-core] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}} (above [extra]):
  
  [haskell]
+
  [haskell-core]
  Server = http://xsounds.org/~haskell/$arch
+
  Server = http://xsounds.org/~haskell/core/$arch
  
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].
+
or
  
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.
+
[haskell-core]
 +
Server = http://www.kiwilight.com/haskell/core/$arch
 +
 
 +
The set of packages in the [haskell-core] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].
 +
 
 +
Putting [haskell-core] above [extra] will ensure that the packages from [haskell-core] take precedence, in case of duplicate packages in the two repositories.
 +
 
 +
The repositories provide both file listings (by using {{ic|repo-add --files}}), package deltas ({{ic|repo-add --delta}}), and both packages and the database are signed.  The fingerprint of the key used for signing is:
 +
 
 +
  pub  2048D/4209170B 2012-12-26
 +
        Key fingerprint = F310 4992 EBF2 4EB8 72B9  7B9C 32B0 B453 4209 170B
 +
  uid                  ArchHaskell (Magnus Therning) <magnus@therning.org>
 +
  sub  2048D/A418C0FE 2012-12-26
 +
 
 +
If you use {{ic|SigLevel &#61; Required TrustedOnly}} in {{ic|/etc/pacman.conf}} for [haskell-core], then you need to do {{ic|sudo pacman-key --lsign-key 4209170B}} to add Magnus Therning's key.
  
 
=== [haskell-web] ===
 
=== [haskell-web] ===
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.
+
The [haskell-web] repository builds on [haskell-core], providing several more packages, especially those useful for web applications.
The first test towards this was [https://github.com/EffeErre/habs-extra habs-extra]. [haskell-extra] is now deprecated.
+
The new version is [haskell-web], introduced [http://www.haskell.org/pipermail/arch-haskell/2012-October/002214.html here]:
+
  
 
  [haskell-web]
 
  [haskell-web]
 
  Server = http://archhaskell.mynerdside.com/$repo/$arch
 
  Server = http://archhaskell.mynerdside.com/$repo/$arch
  
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].
+
Add it after [haskell-core].
  
=== AUR and other places ===
+
=== Last resorts ===
 
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]
 
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]
 
+
* cabal-install directly
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 like regular [[Arch User Repository|AUR]] packages.
+
 
+
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.
+
  
 
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.
 
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.
+
If you have the time, it is recommended to use cblrepo and create something like [haskell-web], which can then be added to the collection of haskell-providing repositories.
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.
+
 
+
== Guidelines ==
+
 
+
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}
+
 
+
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 {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.
+
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].
+
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.
+
 
+
===cabal2arch: an example===
+
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:
+
 
+
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 [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:
+
 
+
{{bc|<nowiki>
+
% cd /tmp
+
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal
+
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal
+
Feeding the PKGBUILD to `makepkg -g`...
+
==> Retrieving Sources...
+
  -> Downloading pandoc-1.6.0.1.tar.gz...
+
--2011-05-14 07:25:39--  http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz
+
Resolving hackage.haskell.org... 69.30.63.204
+
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.
+
HTTP request sent, awaiting response... 200 OK
+
Length: 355477 (347K) [application/x-tar]
+
Saving to: “pandoc-1.6.0.1.tar.gz.part”
+
 
+
    0K .......... .......... .......... .......... .......... 14%  210K 1s
+
    50K .......... .......... .......... .......... .......... 28%  393K 1s
+
  100K .......... .......... .......... .......... .......... 43%  338K 1s
+
  150K .......... .......... .......... .......... .......... 57%  419K 0s
+
  200K .......... .......... .......... .......... .......... 72%  404K 0s
+
  250K .......... .......... .......... .......... .......... 86%  554K 0s
+
  300K .......... .......... .......... .......... .......  100%  506K=0.9s
+
 
+
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]
+
 
+
==> Generating checksums for source files...
+
</nowiki>}}
+
 
+
Checking what was created:
+
 
+
% ls
+
haskell-pandoc
+
% cd haskell-pandoc
+
% ls
+
haskell-pandoc.install PKGBUILD
+
 
+
You can now inspect the PKGBUILD and install script for the library:
+
 
+
{{bc|<nowiki>
+
# Maintainer:
+
_hkgname=pandoc
+
pkgname=haskell-pandoc
+
pkgver=1.6.0.1
+
pkgrel=1
+
pkgdesc="Conversion between markup formats"
+
url="http://hackage.haskell.org/package/${_hkgname}"
+
license=('GPL')
+
arch=('i686' 'x86_64')
+
makedepends=()
+
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')
+
options=('strip')
+
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
+
install=${pkgname}.install
+
md5sums=('d19a630462595941b3100dff6f839aa3')
+
build() {
+
    cd ${srcdir}/${_hkgname}-${pkgver}
+
    runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --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}
+
}
+
</nowiki>}}
+
 
+
It follows the conventions for Haskell packages:
+
 
+
* Libraries are prefixed with {{ic|haskell-}}
+
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|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.
+
 
+
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}
+
  
===Guidelines for Libraries===
+
== Improving ArchHaskell ==
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:
+
  
* libraries have their cabal names prefixed with {{ic|haskell-}}
+
=== Community ===
* all libraries have a dependency on {{pkg|ghc}}
+
See the [[ArchHaskell]] community page and get in touch via the mailing list or the IRC channel.
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD
+
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"
+
  
Registering Haskell libraries is done via a register hook, see above.
+
=== Overview ===
 +
The plan is to have one user-facing repository, [haskell], which merges the packages available in various satellite repositories (like [haskell-web]), thereby distributing the maintenance load.
 +
One satellite repo is special, the [haskell-core] repository, which provides packages that are dependencies of all the other satellites.
  
===Guidelines for Programs ===
+
=== [haskell-core] maintenance ===
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install
+
Ensure:
 +
* [haskell-core] is an Arch repo hosted at kiwilight and xsounds.
 +
* [haskell-core] is in sync with the [https://github.com/archhaskell/habs habs] cblrepo database.
  
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time 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.
+
=== Other repo maintenance ===
 +
For example, for haskell-foo, ensure:
 +
* haskell-foo is a cblrepo database, possibly using packages from [haskell-core] as DistroPkgs.
 +
* Whenever [haskell-core] is updated, haskell-foo's database is updated to match within a reasonable time.
  
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.
+
=== Creating another repo ===
  
== Haskell Build Order ==
+
=== List of satellite repos ===
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib
+

Revision as of 12:07, 25 April 2013

Template:Package Guidelines

Haskell is well supported on Arch Linux. GHC and a few core packages are available in the official repositories. For more serious Haskellers, the ArchHaskell community project provides many packages from Hackage, and the number is growing.

See the ArchHaskell community page for contact details and ways to help.

Haskell Packages

To use Haskell on Arch Linux, you have two mutually exclusive options:

  1. Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the extra and community repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.
  2. Use the ArchHaskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them. A note for xmonad users: if you switch to this option, you need to install the haskell-xmonad package instead of xmonad (which is in the official community repo and has different dependencies).

[haskell-core]

The [haskell-core] repository is the base repository of packages maintained by the ArchHaskell team. [haskell-core] can be accessed by adding the following entry to /etc/pacman.conf (above [extra]):

[haskell-core]
Server = http://xsounds.org/~haskell/core/$arch

or

[haskell-core]
Server = http://www.kiwilight.com/haskell/core/$arch

The set of packages in the [haskell-core] repository is derived from the habs tree officially located here. A tool called cblrepo is used to keep the habs tree synchronized with the official Haskell packages from Hackage.

Putting [haskell-core] above [extra] will ensure that the packages from [haskell-core] take precedence, in case of duplicate packages in the two repositories.

The repositories provide both file listings (by using repo-add --files), package deltas (repo-add --delta), and both packages and the database are signed. The fingerprint of the key used for signing is:

 pub   2048D/4209170B 2012-12-26
       Key fingerprint = F310 4992 EBF2 4EB8 72B9  7B9C 32B0 B453 4209 170B
 uid                  ArchHaskell (Magnus Therning) <magnus@therning.org>
 sub   2048D/A418C0FE 2012-12-26

If you use SigLevel = Required TrustedOnly in /etc/pacman.conf for [haskell-core], then you need to do sudo pacman-key --lsign-key 4209170B to add Magnus Therning's key.

[haskell-web]

The [haskell-web] repository builds on [haskell-core], providing several more packages, especially those useful for web applications.

[haskell-web]
Server = http://archhaskell.mynerdside.com/$repo/$arch

Add it after [haskell-core].

Last resorts

Unfortunately, many of the packages in the AUR are outdated due to a lack of resources. If you have the time, it is recommended to use cblrepo and create something like [haskell-web], which can then be added to the collection of haskell-providing repositories.

Improving ArchHaskell

Community

See the ArchHaskell community page and get in touch via the mailing list or the IRC channel.

Overview

The plan is to have one user-facing repository, [haskell], which merges the packages available in various satellite repositories (like [haskell-web]), thereby distributing the maintenance load. One satellite repo is special, the [haskell-core] repository, which provides packages that are dependencies of all the other satellites.

[haskell-core] maintenance

Ensure:

  • [haskell-core] is an Arch repo hosted at kiwilight and xsounds.
  • [haskell-core] is in sync with the habs cblrepo database.

Other repo maintenance

For example, for haskell-foo, ensure:

  • haskell-foo is a cblrepo database, possibly using packages from [haskell-core] as DistroPkgs.
  • Whenever [haskell-core] is updated, haskell-foo's database is updated to match within a reasonable time.

Creating another repo

List of satellite repos