[Nix-dev] Using several versions of GHC at once

Peter Simons simons at cryp.to
Wed Jun 12 11:40:24 CEST 2013


Hi Nikita,

 > According to [1], it should be possible to use multiple versions at once.

you are right, the wiki page is misleading. As others have pointed out
already, it is not possible to install multiple versions of GHC into the
same profile, because these packages collide in binaries like "bin/ghc"
or "bin/runhaskell", which each version of GHC provides.

The way to go is to create a separate profile for every version of GHC
that you want to use like so:

  $ nix-env -p ~/ghc-6.10.4 -iA nixpkgs.haskellPackages_ghc6104.ghc
  $ nix-env -p ~/ghc-7.6.3  -iA nixpkgs.haskellPackages_ghc762.ghc

Now, you can add both of those profiles into your command search path:

  export PATH="$HOME/ghc-7.6.3/bin:$HOME/ghc-6.10.4/bin:$PATH"

Unversioned commands like "ghc" will refer to GHC 7.6.3. If you want to
run an older version of GHC, then you'll have to invoke it explicitly as
"ghc-6.10.4".

Take care,
Peter



More information about the nix-dev mailing list