[Nix-dev] How to set up your Haskell environment (was: Help with ghc errors after nix-channel --update)

Raahul Kumar raahul.kumar at gmail.com
Thu Dec 18 10:28:58 CET 2014


Peter, Carlos,

Would you recommend this as the ideal way to install Haskell in Nixos now?

Aloha,
RK.

On Tue, Dec 16, 2014 at 11:17 PM, Peter Simons <simons at cryp.to> wrote:
>
> Hi Carlo,
>
>  > for completeness, could you post a version in which this approach is
>  > used in conjunction with ghcWithPackages?
>
> first of all, your ~/.bashrc should contain these settings:
>
>  | NIX_GHC_VERSION=$(ghc --numeric-version)
>  | export NIX_GHC="$HOME/.nix-profile/bin/ghc"
>  | export NIX_GHCPKG="$HOME/.nix-profile/bin/ghc-pkg"
>  | export NIX_GHC_DOCDIR="$HOME/.nix-profile/share/doc/ghc/html"
>  | export NIX_GHC_LIBDIR="$HOME/.nix-profile/lib/ghc-${NIX_GHC_VERSION}"
>
> People who use more than one profile and who don't want to commit to a
> single location for their active Haskell environment can use the
> following instead:
>
>  | NIX_GHC=$(type -p ghc)
>  | if [ -n "$NIX_GHC" ]; then
>  |   eval $(grep export "$NIX_GHC")
>  | fi
>
> The advantage of the first snippet is that you don't need to re-source
> your ~/.bashrc after an nix-env update. The advantage of the second
> snippet is that these variables will point directly into the /nix store,
> so it doesn't matter what the exact path of your profile is.
>
> Now, here is the setup of the Haskell environment:
>
>  | # ~/.nixpkgs/config.nix
>  |
>  | {
>  |   packageOverrides = super: let self = super.pkgs; in
>  |   {
>  |     haskellDevEnv = self.haskellPackages.ghcWithPackages (p: with p; [
>  |       async attoparsec caseInsensitive fgl GLUT GLURaw haskellSrc
>  |       hashable html HTTP HUnit mtl network OpenGL OpenGLRaw parallel
>  |       parsec QuickCheck random regexBase regexCompat regexPosix split
> stm
>  |       syb text transformers unorderedContainers vector /*xhtml*/ zlib
>  |       # tools
>  |       cabalInstall
>  |       ghcMod
>  |       xmonad xmonadContrib xmonadExtras xmobar
>  |       haskintex
>  |     ]);
>  |
>  |     haskellPackages = super.haskellPackages.override {
>  |       extension = self: super: {
>  |         abcnotation = self.callPackage ./abcnotation.nix {};
>  |         prettify = self.callPackage ./prettify.nix {};
>  |       };
>  |     };
>  |   };
>  | }
>
> The first stanza defines a derivation that contains GHC plus all those
> listed libraries. (Note that because of a bug in GHC 7.8.3 the 'xhtml'
> package cannot be included into such a generated environment, so the
> package is commented out.) To include this derivation into your user
> profile, run "nix-env -iA haskellDevEnv". The argument to
> haskellPackages.ghcWithPackages is a function that takes the Haskell
> package set as an argument and returns a list of packages to be merged
> into one derivation. Taking the package set as an argument allows the
> list of libraries to be agnostic of the compiler version you're using.
> For example:
>
>   haskellPackages_ghc704.ghcWithPackages (p: [p.mtl]);
>   haskellPackages_ghc783.ghcWithPackages (p: [p.mtl]);
>
> Both derivations give you an environment with GHC plus the 'mtl' library,
> but one is based on GHC 7.0.4 and the other is based on GHC 7.8.3.
>
> The second stanza extends the standard Haskell package set from Nixpkgs
> with two locally defined packages that were created by running:
>
>  $ cabal2nix cabal://prettify >~/.nixpkgs/prettify.nix
>  $ cabal2nix cabal://abcnotation >~/.nixpkgs/abcnotation.nix
>
> These packages are available like any other Nixpkgs Haskell library and
> can be used in combination with ghcWithPackages.
>
> Best regards,
> Peter
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20141218/2aa2e5ea/attachment.html 


More information about the nix-dev mailing list