[Nix-dev] How to set a specific GHC version?

Eric Sagnes eric.sagnes at gmail.com
Thu Aug 6 10:30:31 CEST 2015


Hi

Have you tried the example from the manual [1]?
You can set GHC version by changing the "ghc7101" of the 
first line to the version name you want.

You can use the following command to check the available versions of ghc:
nix-env -f "<nixpkgs>" -qaP -A haskell.compiler

Cheers,

[1] http://hydra.nixos.org/build/24422016/download/1/nixpkgs/manual.html#how-to-create-ad-hoc-environments-for-nix-shell

On Wed, Aug 05, 2015 at 10:59:31PM -0700, Hilco Wijbenga wrote:
> Hi all,
> 
> This must be very simple but I have been unable to figure it out.
> Somewhere on the great, wide Internet I found how to create a
> default.nix and a shell.nix to set up a basic Haskell development
> environment (see [1] and [2]).
> 
> That works fine but gets me whatever the default GHC currently is. I
> would like to set explicitly which version I'm using. Once I've got
> that covered, how do I set explicit versions for the packages I'm
> including as well? Just adding a version to the package name doesn't
> work.
> 
> Finally, (specifically for the first question) how could I have
> figured that out for my self? Could someone teach me to fish? :-) I
> did read up on Nix expressions and looked at the nixpkgs.git but I was
> unable to figure it out.
> 
> (I have installed Nix on my Gentoo box. I've removed all Gentoo
> Haskell related packages and I'm trying to set up a Haskell
> development environment using Nix only.)
> 
> Cheers,
> Hilco
> 
> [1] default.nix:
> { stdenv, haskellngPackages }:
> 
> let
>   env = haskellngPackages.ghcWithPackages (p: with p; [
>     cabal-install
>     cabal2nix
>     classy-prelude
>   ]);
> in
>   stdenv.mkDerivation {
>     name        = "project-name";
>     buildInputs = [env];
>     shellHook   = ''
>       export NIX_GHC="${env}/bin/ghc"
>       export NIX_GHCPKG="${env}/bin/ghc-pkg"
>       export NIX_GHC_DOCDIR="${env}/share/doc/ghc/html"
>       export NIX_GHC_LIBDIR=$( $NIX_GHC --print-libdir )
>     '';
>   }
> 
> [2] shell.nix:
> { pkgs ? (import <nixpkgs> {}) }:
> 
> (import ./default.nix) {
>     stdenv            = pkgs.stdenv;
>     haskellngPackages = pkgs.haskellngPackages;
>   }
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev

-- 
Eric Sagnes
サニエ エリック


More information about the nix-dev mailing list