Cached Haskell IDE Engine Nix builds for all GHC versions
This repository provides cached Nix builds for the latest stable Haskell IDE Engine (HIE) for all supported GHC versions. It is intended to be a successor to hie-nix, which only provides a changing subset of versions. This project solves the problem of having mismatched HIE and project GHC versions, which is almost impossible to avoid if you use a globally installed HIE and have many projects.
For unstable versions see this section.
Installation
Cached builds
If you wish to use prebuilt binaries, available on both Linux and macOS, configure the all-hies
cache with these instructions, or if you have cachix installed already:
cachix use all-hies
Note: Due to an issue with cachix you might have to restart the nix daemon for this to take effect, refer to this issue.
After configuring the cache, proceed to the install instructions below.
Building without cached builds
On Linux and some versions of macOS, building HIE yourself is also possible and is in fact the default if you don’t configure cachix as specified above. The build has a lot of dependencies however, so be prepared to wait a while for it to finish.
The only known macOS version to succeed in building all HIE versions is High Sierra, which was used to build the caches. MacOS Mojave specifically doesn’t work for some HIE versions.
Declarative installation (NixOS, home-manager or similar)
This section describes installation with NixOS, but this is easily adaptable to home-manager or other declarative installation methods by using the appropriate file and options. E.g. with home-manager, use ~/.config/nixpkgs/home.nix
instead of /etc/nixos/configuration.nix
and assign to home.packages
instead of environment.systemPackages
.
To install stable HIE for a specific set of GHC versions, use the following in your /etc/nixos/configuration.nix
. This will install hie
and hie-wrapper
binaries which are both HIE versions that select the correct version out of the given ones for your projects. Note that hie
is just a symlink to hie-wrapper
.
let
all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
in
{
environment.systemPackages = [
# Install stable HIE for GHC 8.6.4, 8.6.3 and 8.4.3
(all-hies.selection { selector = p: { inherit (p) ghc864 ghc863 ghc843; }; })
];
}
To install all stable HIE versions for all supported GHC versions use the following. Warning: Requires ~30GB (or <10GB with compression) of space!
let
all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
in
{
environment.systemPackages = [
# Install all stable HIE versions
(all-hies.selection { selector = p: p; })
];
}
nix-env
installation
To install stable HIE for a specific set of GHC versions use the following. This will install hie
and hie-wrapper
binaries which are both HIE versions that select the correct version out of the given ones for your projects. Note that hie
is just a symlink to hie-wrapper
.
nix-env -iA selection --arg selector 'p: { inherit (p) ghc864 ghc863 ghc843; }' -f https://github.com/infinisil/all-hies/tarball/master
To install all stable HIE versions for all supported GHC versions use the following. Warning: Requires ~30GB (or <10GB with compression) of space!
nix-env -iA selection --arg selector 'p: p' -f https://github.com/infinisil/all-hies/tarball/master
Unstable versions
Sometimes unstable HIE versions are also provided but without build caches, so refer to the section on building without cached builds. If no unstable version is provided the installation described here will be the same as the stable version.
If you just want to get a HIE version for a GHC that stable doesn’t support yet, use the unstableFallback
attribute, which uses stable if it’s available for that GHC version, but falls back to unstable if not. For unstable versions only, use the unstable
attribute. Both unstable
and unstableFallback
provide the selection
function just like the standard stable set, so the installation is very similar:
NixOS
let
all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
in {
environment.systemPackages = [
# Install stable HIE for GHC versions 8.6.4 and 8.6.5 if available and fall back to unstable otherwise
(all-hies.unstableFallback.selection { selector = p: { inherit (p) ghc864 ghc865; }; })
# Install unstable HIE for GHC versions 8.4.4 and 8.6.5
(all-hies.unstable.selection { selector = p: { inherit (p) ghc844 ghc865; }; })
];
}
nix-env
# Install stable HIE for GHC versions 8.6.4 and 8.6.5 if available and fall back to unstable otherwise
nix-env -iA unstableFallback.selection --arg selector 'p: { inherit (p) ghc864 ghc865; }' -f https://github.com/infinisil/all-hies/tarball/master
# Install unstable HIE for GHC versions 8.4.4 and 8.6.5
nix-env -iA unstable.selection --arg selector 'p: { inherit (p) ghc844 ghc865; }' -f https://github.com/infinisil/all-hies/tarball/master
hie-bios versions
There is a HIE PR for using @mpickering’s hie-bios. This PR can be built with by using the bios
attribute, e.g. all-hies.bios.selection { selector p: { inherit (p) ghc865; }; }
.
Updating this repository
This section is only for all-hies developers and not intended for end users.
To have the updater available, run
alias update="$(nix-build --no-out-link update.nix)/bin/update"
Then you can use it as follows to generate the stable/unstable set (or any other set)
update --name stable --revision 0.10.0.0
update --name unstable --revision master
update --name bios --revision hie-bios --hie-repo https://github.com/mpickering/haskell-ide-engine
Then to build stable/unstable package sets on high-end machines with 32GB RAM or more, you can use
nix-build -A versions --max-jobs auto --cores 1
nix-build -A unstable.versions --max-jobs auto --cores 1
However if you don’t have that much RAM, this leads to a lot of thrashing due to the many different dependencies between GHC versions. Use something like the following to prevent this (note that this uses the jq
command from the jq
package):
nix-instantiate --eval -E 'builtins.attrNames (import ./. {}).versions' --json | jq -r '.[]' \
| xargs -I{} -P1 nix-build -A versions.{} --max-jobs auto --cores 1
nix-instantiate --eval -E 'builtins.attrNames (import ./. {}).unstable.versions' --json | jq -r '.[]' \
| xargs -I{} -P1 nix-build -A unstable.versions.{} --max-jobs auto --cores 1
Both the update
and nix-build
’s take a long time, but both do a lot of intermediate caching and are idempotent, so they can be interrupted and resumed at any time without losing too much progress. If builds fail for some reason, the overrides
directory can be used to add GHC-specific overrides.