ghcs.nix
This is a repository of nix derivations for various GHC versions. The intent is to have complete coverage of all recent GHC releases.
There is a Cachix cache containing pre-built binaries here.
Usage
First install nix
and
(if you want to use the binary cache) the cachix
client:
$ 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:
$ git clone https://gitlab.haskell.org/bgamari/ghcs-nix
$ nix build -f . ghc-9_2_1-rc1
There is also a convenient get_ghc
script which can be used to populate a
symlink to a requested set of compilers:
$ ./get_ghc 9.0.1
$ ./ghcs/9.0.1/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.0.1
You can also get a compiler without cloning the repository:
$ nix run -f https://gitlab.haskell.org/bgamari/ghcs-nix/-/archive/master/ghcs-nix-master.tar.gz ghc-9_0_1
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.0.1
Your compiler will be available via the created result/
symlink:
$ 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:
$ 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.
Additionally, there are a variety of options for configuring the GHC build. See
the argument block in 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:
$ nix build -f . '((import ./. {}).ghc_8_10_2.override { enableIntegerSimple = true; })'
Other resources
-
@mpickering
'sghc-artefact-nix
is another approach for using existing GHC binary distributions under NixOS. -
@mpickering
'sold-ghc-nix
is a collection of GHC releases packaged usingghc-artefact-nix
. -
head.hackage
is a set of patches for adapting Hackage packages for use with GHC pre-releases.