VSCode remote SSH and HIE / lsp in nix-shell? - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

o1lo01ol1o

Does anyone have a configuration for using VSCode's remote ssh connection to use h-ide where the connection needs to first enter a nix-shell? I've tried using direnv but I can't seem to make the .envrc load the nix shell before h-ide gives up on finding cabal (and any other dependency needed from the nix-shell in question.

Sridhar Ratnakumar

My template doesn't require direnv: https://github.com/srid/haskell-template

It should "just work" (I use remote ssh all the time), due to arrterian.nix-env-selector.

For some projects, I use direnv, and you just need use flake in ./.envrc, followed by direnv allow. Then, when you open the workspace remotely, keep all tabs closed. Open flake.nix first, wait a second or two, then open a .hs file.

Sridhar Ratnakumar

For some reason HLS breaks when a workspace is opened with pre-opened .hs tabs. Also keep your terminal turned off at window open time.

o1lo01ol1o

Sridhar Ratnakumar said:

My template doesn't require direnv: https://github.com/srid/haskell-template

It should "just work" (I use remote ssh all the time), due to arrterian.nix-env-selector.

For some projects, I use direnv, and you just need use flake in ./.envrc, followed by direnv allow. Then, when you open the workspace remotely, keep all tabs closed. Open flake.nix first, wait a second or two, then open a .hs file.

Huh, I've tried the latter with obelisk's ob shell in direnv and no matter how long i give it before opening tabs, it always breaks. Have you been able to do it with obelisk?

To be clear, I can allow the direnv and I can see the VM's cpu resources spike as things load, so I know it's working. I just can't seem to make h-ide load at the right time.

Sridhar Ratnakumar

Oh, obelisk is a different beast. They don't even support HLS afaict. I don't use ghcjs anymore, but I think you want https://github.com/obsidiansystems/obelisk/issues/762

o1lo01ol1o

Sridhar Ratnakumar said:

Oh, obelisk is a different beast. They don't even support HLS afaict. I don't use ghcjs anymore, but I think you want https://github.com/obsidiansystems/obelisk/issues/762

I've been using HLS with obelisk for a couple years now without a problem. To do it locally, I simply need to launch code from ob shell (Can also do nix-shell -A shells.ghc but this doesn't load cabal tests.). AFAICT, ob shell just manually builds up a custom nix-shell so it shouldn't be that different.

Sridhar Ratnakumar

(but you still need HLS in nix shell I think)

o1lo01ol1o

Sridhar Ratnakumar said:

(but you still need HLS in nix shell I think)

Yes, that's provided by the shellTools attribute in the nix derivation. can I use ob shell?

o1lo01ol1o

Ah, I see, I missed that issue. Will investigate, thanks!

o1lo01ol1o

There are some issues still with getting the shell loaded prior to VSCode initializing plugins, so I have a hack that just creates an .envrc with the PATH set by ob shell; this appears to load everything correctly.

o1lo01ol1o

Though I'm still working on getting upstream deps in the right place to build HLS with the same GHC used in the project. For some reason, the HLS-VSCode managed HIDE binaries work without a problem on darwin but they break on template haskell splices on linux. The latter breakage causes many of the useful plugins (code lenses, go to, etc) to break.