The language server plugin on my IDE understandably had problems in recognizing imports: Could not find module ‘XMonad...’.. So I tried to provide it an hie.yaml
Where hie-bios.sh is echo "xmonad" >> $HIE_BIOS_OUTPUT (I don’t understand what this does though). I derived the with-ghc path by looking at GHC command in the xmonad path in the store.
I’m sure there’s a better/simpler way to do this without hardcoding paths like this. Suggestions?
This is the only thing that helped me to get LSP support for xmonad
Only addition is that I used nix-tree util to find exact path to my “ghc-…-with-packages” (the dependency of the xmonad-with-packages package)
and that I had to run “haskell-language-server” manually from the directory that contians “xmonad.hs”
and I think that it will not be hard to generate this file from nix expression, so that hash gets subsctituted on system rebuild.
Tried to find any other resource that would explain how to add LSP for xmonad.
Things that got me close, but not close enough:
I am a beginners with both nix and Haskell, so I wanted to provide the learnings I had for future beginners as well
hie-bios.sh
The answer to both OP and I’s question/uncertainty about the hie-bios.sh containing the echo "xmonad" >> $HIE_BIOS_OUTPUT, proposed by the nixos wikipage for xmonad, was found on the README of the hie-bios repository.
Though, even with the README, it was not immediately clear to me, what was going on. So here is a summary, from my understanding:
The purpose of the program, in this case hie-bios.sh, is to provide the Haskell build system with all the options need to build the project. This is done by writing them to the file that the $HIE_BIOS_OUTPUT environment variable points to, which is then later consulted by the build process.
In our case, the option needed isxmonad.
This is why the program echos xmonad to the variable.
Once I had added the environment variable with the proposed temporary file from the wiki, my LSP worked, started by neovim.
export HIE_BIOS_OUTPUT ./options.txt
Hardcoded paths
I have yet to discover a way to avoid the hardcoded path, or dynamically update it.
This is a naive and only semiautomatic selution, but it does not change offen enough for me to try to fix it further.
You could add a similar selution to run when you start your editor or LSP, to further automate it.