##Install Haskell Platform from source with Debian update-alternatives
Scripts to make manual/source installation and management of multiple versions of GHC
and Haskell Platform easy. Bypasses the Debian repos. Works with Debian, Ubuntu, or
any derivative that has the Debian update-alternatives tool available.
###Why?
- Debian/Ubuntu/etc repos seem to consistently lag the current version of GHC and Haskell platform. (Though that might be getting better, judging from how quickly http://packages.ubuntu.com/haskell-platform and http://packages.debian.org/haskell-platform were updated with Platform 2012.2.0.0)
- Install multiple GHC and Haskell Platform versions side-by-side, and easily toggle
between them with
update-alternatives --config. - Upgrade to new versions of GHC and Haskell Platform without overwriting or deleting
the previous. If this causes regressions in your apps, easily roll back to the prior
working version with a simple
update-alternatives --config. - Keep all files of GHC and Haskell Platform together in a single location like
/opt/haskell/ghcand/opt/haskell/platform, instead of spread out over/usr/bin,/usr/lib, and/usr/shareas with anapt-getordpkg -iinstallation. The files are kept in/opt/haskell/andupdate-alternativessoft links them to their system directories. - Easily uninstall with
update-alternatives --remove-all(script included), andrm -rf /opt/haskell. - Run haskell via system PATH instead of user PATH (eg, no need to add
/opt/haskell/ghc/binto your PATH in .profile) - Get used to using
update-alternatives, it's a great tool that makes managing manually installed, multi-version software painless. Java and Scala both work equally well with it.
###I. Install GHC
Note: using older versions here, substitute later versions as necessary, make sure to use the specific GHC version your Platform version requires.
- GHC must be installed before Haskell Platform can be, so...
- download GHC to a temp dir (the binary, not the source, unless you specifically need to build from source and it's worth the long build)
tar -xvf ghc-7.4.1-x86_64-unknown-linux.tar.bzcd ghc-7.4.1./configure --prefix=/opt/haskell/ghc/7.4.1(or wherever you want to install GHC)sudo make installsudo sh ghc-install.sh(see script) (before running, make sure the last line in the script does not overwrite/usr/share/man/man9. If there is already aman9in/usr/share/manthen change the line in the script toman11or something else safe:--slave $MAN/man9 man.ghc $GHC_MAN/man1- test:
cdghc --versionman ghc
###II. Install Haskell Platform
- Download current Haskell-Platform source
tar -xvf haskell-platform-2012.2.0.0.tar.gzcd haskell-platform-2012.2.0.0./configure --prefix=/opt/haskell/platform/2012.2.00sudo makesudo make installsudo sh platform-install.sh(see script)- test:
which cabalcabal update
###III. Troubleshooting
If any errors occurred during build, check that you have the required dependencies.
Also, make sure you have the correct pairs of GHC and Haskell Platform. Each Haskell Platform release is designed to work with a specific version of GHC (scroll down to the chart showing the matching version of GHC for each platform. The latest platform 2013.2.0.0 pairs with GHC 7.6.3).
###IV. XMonad
Optionally, install XMonad using a similar method. However, instead of downloading the source from a website, build it with Cabal into /opt/haskell/xmonad:
cd ~- Get latest version of xmonad and xmonad-contrib
cabal info xmonadcabal info xmonad-contrib
- Build and install both to
/opt, using the version as part of the path. This makes it easy to add future releases side-by-side with this one, each in its own versioned path, and swap between them, or rollback if necessary, usingupdate-alternatives --config xmonad.sudo cabal install xmonad --prefix=/opt/haskell/xmonad/$VERsudo cabal install xmonad-contrib --prefix=/opt/haskell/xmonad-contrib/$VER
- Edit xmonad-install.sh, change the XMONAD_VER and CONTRIB_VER to correct versions from #2.
sudo sh xmonad-install.shxmonad-install.sh- Set up XMonad as you would for a globally installed version.