Skip to content
Snippets Groups Projects
README.mkd 2.06 KiB
Newer Older
Ben Gamari's avatar
Ben Gamari committed
# ghcs.nix

This is a repository of [nix](https://nixos.org/) derivations for various GHC
versions. The intent is to have complete coverage of all recent GHC releases.

There is a [Cachix](https://www.cachix.org/) cache containing pre-built
binaries [here](https://app.cachix.org/cache/ghc).
Ben Gamari's avatar
Ben Gamari committed

## Usage

First [install `nix`](https://nixos.org/download.html#nix-quick-install) and
(if you want to use the binary cache) the [`cachix`
client](https://docs.cachix.org/installation.html):
```bash
$ curl -L https://nixos.org/nix/install | sh
$ nix-env -iA cachix -f https://cachix.org/api/v1/install
$ cachix use ghc
```

Next clone this repository and build the desired compiler:
```bash
$ git clone https://gitlab.haskell.org/bgamari/ghcs-nix
$ nix build -f ./ghcs-nix ghc_9_0_1rc1
```

Your compiler will be available via the created `result/` symlink:
```bash
$ result/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.0.0.20201227
```

You can instruct `cabal-install` to use this compiler via the `-w` flag:
```bash
$ cd my-project/
$ cabal v2-build -w /path/to/result/bin/ghc
```

For use with pre-release GHCs you might want to use the [`head.hackage`
patch-set][head-hackage].

Ben Gamari's avatar
Ben Gamari committed
Additionally, there are a variety of options for configuring the GHC build. See
the argument block in [`ghc.nix`](./ghc.nix) for details. For instance, to
build a compiler against the `integer-simple` (known in more recent GHC
releases as the "native" bignum backend), simply run:
```bash
$ nix build -f . '((import ./. {}).ghc_8_10_2.override { enableIntegerSimple = true; })'
```

Ben Gamari's avatar
Ben Gamari committed
## Other resources

* `@mpickering`'s
  [`ghc-artefact-nix`](https://github.com/mpickering/ghc-artefact-nix) is another
  approach for using existing GHC binary distributions under NixOS.

* `@mpickering`'s [`old-ghc-nix`](https://github.com/mpickering/old-ghc-nix) is
  a collection of GHC releases packaged using `ghc-artefact-nix`.

* [`head.hackage`][head-hackage] is a set of patches for adapting Hackage
  packages for use with GHC pre-releases.

[head-hackage]: http://ghc.gitlab.haskell.org/head.hackage/