How to have "go to definition" in the haskell ecosystem ?!


Still fighting a lot with haskell. I thought nix would be perfect for haskell but I am at a stage where it just make things more complex. My current challenge is to have go to <haskell word under cursor> definition succeed in neovim. My first reflex was to turn to LSP but haskell-ide-engine doesn’t seem ready yet (Go to definition of library methods · Issue #308 · haskell/haskell-ide-engine · GitHub).

My fallback approach (which works great for other languages) is to generate a ctags database readable by neovim. I thus experimented with hasktags/haskdogs but I can’t get it to generate tags for the packages built with the ghc environment (haskdogs on nixos · Issue #4 · grwlf/haskdogs · GitHub). Apparently I need to run cabal update but it complains about the absence of remote servers. I’ve then read about nix-style cabal to no avail.

Thus my question is how do you people achieve “go to definition” for haskell on nixos ?!!!
I tried to program with the doc open in another editor/browser but I can’t take it anymore, “goto” is so much more convenient.

While investigating, the previous problem, I’ve had another one:
from times to times, I have errors about a “./settings” file. I don’t think it comes from my configuration

cabal new-build
exited with an error:
./settings: openFile: does not exist (No such file or directory)

when I look at the strace, there seems to be

18953 openat(AT_FDCWD, "./settings", O_RDONLY|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)

I’ve found a similar post without understanding the root cause /usr/lib/ghc/settings: openFile: does not exist · Issue #766 · DanielG/ghc-mod · GitHub .

How are you using nix and Haskell together? Does nix manage all your Haskell dependencies?

First of all I was able to generate tags for the project at some point \o/
The ./settings: openFile: does not exist (No such file or directory) error still appears though.

I enter the following nix-shell on nixos-unstable. netlink-pm is a pet project I’ve defined in my overlay

with import <nixpkgs> {};

  hie_remote = builtins.fetchTarball {
    url    =;
  hie = (import hie_remote {} ).hie84;

haskellPackages.shellFor {
  packages = p: with p; [ haskellPackages.netlink-pm ];
  withHoogle = true;
  # haskellPackages.stack 
  nativeBuildInputs = [ 
    # haskellPackages.cabal-install 

  # export HIE_HOOGLE_DATABASE=$NIX_GHC_DOCDIR as DOCDIR doesn't exist it won't work
  shellHook = ''
    export HIE_HOOGLE_DATABASE="$NIX_GHC_LIBDIR/../../share/doc/hoogle/index.html"

The hs.cabal for my project:

name: netlink-pm
version: 1.0.0
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.18
build-type: Simple

executable project1
    build-depends: base < 5, netlink
    main-is: daemon.hs
    default-language: Haskell2010

Thanks for the help, I would really like to progress on this project but I am stuck because of this.

If I “touch settings”, then I get a similar error with platformConstants. I forked ghc and seems like it is looking for this list as file ghc/Generate.hs at b1af0aed08c78f42c7dd2505ed9b96d0cbf1d076 · teto/ghc · GitHub. Not sure if that makes sense.

#haskell put me on the list and it’s my fault: I had made changes to haskell’s code to fix a few issues, which I had reverted to exactly rule out this as a problem. Seems like I made a reset --hard on an older commit which brought back my changes and the problem as well. Problem solved. sorry for the noise.