[Nix-dev] Haskell-env (via nix-shell) - am I doing this right?

Peter Simons simons at cryp.to
Fri May 22 21:44:30 CEST 2015


Hi Peter,

 > 3) The ghc argument in shell.nix allows me to specify different
 >    versions of GHC so I can test with multiple versions.  (I'd love
 >    some feedback on how to make this more flexible.)

I use the following "shell.nix" to switch between compiler versions:

    { compiler ? "ghc7101" }:

    with (import <nixpkgs> {}).pkgs;
    let
      ghc = haskell.packages.${compiler}.ghcWithPackages
              (pkgs: with pkgs; [ aeson lens monad-par ]);
    in
    stdenv.mkDerivation {
      name = "my-haskell-env-0";
      buildInputs = [ ghc ];
      shellHook = "eval $(grep export ${ghc}/bin/ghc)";
    }

Now run "nix-shell --argstr compiler ghc784" to select a compiler other
than the default.

I hope this helps,
Peter



More information about the nix-dev mailing list