···
6
+
# User's Guide to the Haskell Infrastructure
7
-
# How to install Haskell packages
9
+
## How to install Haskell packages
Nixpkgs distributes build instructions for all Haskell packages registered on
[Hackage](http://hackage.haskell.org/), but strangely enough normal Nix package
···
Also, the attributes `haskell.compiler.ghcXYC` and
`haskell.packages.ghcXYC.ghc` are synonymous for the sake of convenience.
114
-
# How to create a development environment
116
+
## How to create a development environment
116
-
## How to install a compiler
118
+
### How to install a compiler
A simple development environment consists of a Haskell compiler and the tool
`cabal-install`, and we saw in section [How to install Haskell packages] how
···
no longer work after garbage collection, then you'll have to re-run `cabal
configure` inside of a new `nix-shell` environment.
165
-
## How to install a compiler with libraries
167
+
### How to install a compiler with libraries
GHC expects to find all installed libraries inside of its own `lib` directory.
This approach works fine on traditional Unix systems, but it doesn't work for
···
export NIX_GHC_LIBDIR="$HOME/.nix-profile/lib/ghc-$($NIX_GHC --numeric-version)"
260
-
## How to install a compiler with libraries, hoogle and documentation indexes
262
+
### How to install a compiler with libraries, hoogle and documentation indexes
If you plan to use your environment for interactive programming, not just
compiling random Haskell code, you might want to replace `ghcWithPackages` in
···
322
-
## How to create ad hoc environments for `nix-shell`
324
+
### How to create ad hoc environments for `nix-shell`
The easiest way to create an ad hoc development environment is to run
`nix-shell` with the appropriate GHC environment given on the command-line:
···
`$PATH` already to use it here --- the `nix-shell` environment does not provide
372
-
# How to create Nix builds for your own private Haskell packages
374
+
## How to create Nix builds for your own private Haskell packages
If your own Haskell packages have build instructions for Cabal, then you can
convert those automatically into build instructions for Nix using the
`cabal2nix` utility, which you can install into your profile by running
379
-
## How to build a stand-alone project
381
+
### How to build a stand-alone project
For example, let's assume that you're working on a private project called
`foo`. To generate a Nix build expression for it, change into the project's
···
436
-
## How to build projects that depend on each other
438
+
### How to build projects that depend on each other
If you have multiple private Haskell packages that depend on each other, then
you'll have to register those packages in the Nixpkgs set to make them visible
···
$ nix-shell "<nixpkgs>" -A haskellPackages.bar.env
471
-
# Miscellaneous Topics
473
+
## Miscellaneous Topics
473
-
## How to build with profiling enabled
475
+
### How to build with profiling enabled
Every Haskell package set takes a function called `overrides` that you can use
to manipulate the package as much as you please. One useful application of this
···
Then, replace instances of `haskellPackages` in the `cabal2nix`-generated
`default.nix` or `shell.nix` files with `profiledHaskellPackages`.
497
-
## How to override package versions in a compiler-specific package set
499
+
### How to override package versions in a compiler-specific package set
Nixpkgs provides the latest version of
[`ghc-events`](http://hackage.haskell.org/package/ghc-events), which is 0.4.4.0
···
cannot use GHC 7.10.x at all for some reason, the approach of downgrading to an
older version might be useful.
563
-
## How to recover from GHC's infamous non-deterministic library ID bug
565
+
### How to recover from GHC's infamous non-deterministic library ID bug
GHC and distributed build farms don't get along well:
···
rm /nix/var/nix/manifests/*
rm /nix/var/nix/channel-cache/*
589
-
## Builds on Darwin fail with `math.h` not found
591
+
### Builds on Darwin fail with `math.h` not found
Users of GHC on Darwin have occasionally reported that builds fail, because the
compiler complains about a missing include file:
···
in their `~/.bashrc` file to avoid the compiler error.
606
-
## Using Stack together with Nix
608
+
### Using Stack together with Nix
-- While building package zlib-0.5.4.2 using:
runhaskell -package=Cabal-1.22.4.0 -clear-package-db [... lots of flags ...]
···
The same thing applies to `cabal configure`, of course, if you're
building with `cabal-install` instead of Stack.
669
-
## Creating statically linked binaries
671
+
### Creating statically linked binaries
There are two levels of static linking. The first option is to configure the
build with the Cabal flag `--disable-executable-dynamic`. In Nix expressions,
···
- The Youtube video [Nix Loves Haskell](https://www.youtube.com/watch?v=BsBhi_r-OeE)
provides an introduction into Haskell NG aimed at beginners. The slides are