Skip to content

Integration of NixOS/Nix with Haskell IDE Engine (HIE) and Emacs (Spacemacs)

1. Install the Cachix:

2. Installation of HIE:

2.1. Provide cached builds

cachix use all-hies

2.2.a. Installation on NixOS distribution:

{ config, pkgs, ... }:


  all-hies = import (fetchTarball "") {};

in {
  environment.systemPackages = with pkgs; [

    (all-hies.selection { selector = p: { inherit (p) ghc865 ghc864; }; })


Insert your GHC versions.

Switch to new configuration:

sudo -i nixos-rebuild switch

2.2.b. Installation with Nix package manager:

nix-env -iA selection --arg selector 'p: { inherit (p) ghc865 ghc864; }' -f ''

Insert your GHC versions.

3. Emacs (Spacemacs) configuration:



  (lsp :variables
       default-nix-wrapper (lambda (args)
                              (append (list "nix-shell" "-I" "." "--command" )
                                      (list (mapconcat 'identity args " "))
                              (list (nix-current-sandbox))

       lsp-haskell-process-wrapper-function default-nix-wrapper

  (haskell :variables
           haskell-enable-hindent t
           haskell-completion-backend 'lsp
           haskell-process-type 'cabal-new-repl


 dotspacemacs-additional-packages '(


auto-complettion configures YASnippet.

nix-sandbox ( has a great helper functions. Using nix-current-sandbox function in default-nix-wrapper that used to properly configure lsp-haskell-process-wrapper-function.

Configuration of the lsp-haskell-process-wrapper-function default-nix-wrapper is a key for HIE to work in nix-shell

Inside nix-shell the haskell-process-type 'cabal-new-repl is required.

/Configuration was reassembled from: & its authors config: /

Refresh Emasc.

4. Open the Haskell file from a project

Open system monitor, observe the process of environment establishing, packages loading & compiling.

5. Be pleased writing code

Now, the powers of the Haskell, Nix & Emacs combined. It's fully in your hands now. Be cautious - you can change the world.

6. (optional) Debugging

  1. If recieving sort-of:
readCreateProcess : cabal-helper-wrapper failure

HIE tries to run cabal operations like on the non-Nix system. So it is a problem with detection of nix-shell environment, running inside it.

  1. If HIE keeps getting ready, failing & restarting - check that the projects ghc --version is declared in your all-hie NixOS configuration.