The whole procedure is very similar to that described for Spacemacs. If you miss somethings here, it might be on that other page. However, this page should be self-contained (with some links to other pages to reduce duplication in the wiki).
Some animations to demonstrate what you can expect:
For the context of this page, only the argument withIde = true; matters. It makes sure that the resulting Nix environments contain the right ghcide executable.
Build GHC with ghc.nix
❗ The first time you call nix-shell in the ghc source folder, all dependencies are downloaded and (if needed) built. Building ghcide takes much time. Consider to enable cachix, a binary cache for Nix packages: spacemacs/cachix
Some source code files are generated during build.
Build GHC in the context defined by ghc.nix and shell.nix, e.g.
ccls needs a compile_commands.json (JSON Compilcation Database) file as configuration. This file is mostly a mapping of *.c filenames to C compiler arguments.
compile_commands.json is generated by bear, a tool that intercepts all calls to the C compiler. That means, you have to trigger a full (re-)build with bear, even if you already got a fully compiled GHC project.
Create two distinct workspaces for the GHC compiler and Hadrian.
The simplest way is to:
File -> New Window
File -> Open Folder... (in the new window)
File -> Save Workspace As... (in the new window)
The folder of your GHC compiler workspace is the source root of the cloned GHC repository. The Hadrian folder, is hadrian/ in that previously described folder.
So, e.g. if your GHC source folder has the path /home/sven/src/ghc, then the two folders are:
/home/sven/src/ghc for GHC
/home/sven/src/ghc/hadrian for Hadrian
Works out of the box! It automatically finds the compile_commands.json file and uses it as configuration.
The are the arguments to the ghcide plugin: Hic: Arguments (hic.arguments) and Hic: Executable Path (hic.executablePath).
You have to set them per workspace, i.e. hic.arguments differs for the GHC compiler and the Hadrian workspace.