Unable to use Haskell for Visual Studio Code

Seems the extension Haskell for Visual Studio Code depends on GHCup. However I wasn’t able to install.
There’s also a long lasting issue nix-shell -p haskellPackages.ghcup fails.
Is there a straight forward approach to setup a Haskell project with hls support in IDE?

Unfortunately there’s no word about IDE support, nor about GHCup on the wiki/Haskell

If you are already exposed to flakes (and have direnv configured), you could use my flake template (or any other flake template - there are plenty) to help you to get into programming Haskell with Nix easily:

nix flake new --template sourcehut:~bwolf/flake-templates#haskell foo                                                                                                                                                                                                                      
cd foo
echo use flake > .envrc
direnv allow
cabal init # Many prompts, just follow
cabal build
codium .

In VScode or Codium, set "haskell.serverExecutablePath": "haskell-language-server". Then reload the window and open app/Main.hs and voilà. In my case I’m ignoring the message about GHCup.

1 Like

I can recommend GitHub - srid/haskell-flake: A `flake-parts` Nix module for Haskell development.

1 Like

Thanks for answering my question @bwolf. The hint regarding haskell.serverExecutablePath. Helped indeed to get hls support in VScode

$ cat .vscode/settings.json
{ "haskell.serverExecutablePath": "haskell-language-server" }

Yeah indeed, they changed their lookup strategy for HLS from being path based, which works in Nix cases out of the box to some dependency (as it looks like to me) to being dependent to GHCup. But the escape hatch works so far (which is good and I think that should be the default).

As I said, there are plenty of flakes out there. It is completely valid to use them. I personally prefer to stick to built-in functionality of nixpkgs as long as I can, because for me and newcomers, this adds the burden of additional layers and complexity. Thanks.

Having a resolution for the issue nix-shell -p haskellPackages.ghcup fails would be desirable state for Haskell on NixOS in my opinion. I would love to have the possibility to use ghcup, like I use rustup

I believe in the settings of the options, you can set it to find HLS in PATH so you can completely ignore ghcup