NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.46k stars 12.95k forks source link

haskell-language-server provides its own GHC in a devshell #225895

Open deemp opened 1 year ago

deemp commented 1 year ago

Describe the bug

HLS brings its own GHC into a devshell. If I write HLS before custom ghc with packages in buildInputs, I'll get a GHC from HLS.

Steps To Reproduce

Here's a flake with a demo

https://github.com/deemp/gists/blob/d6ec5c859dc6c3e979282fdc1b2bf595c671c239/hlsBringsGHC/flake.nix

Expected behavior

HLS doesn't bring its GHC into a devshell.

Notify maintainers

@cdepillabout

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
cdepillabout commented 1 year ago

@deemp Thanks for the nice reproducible example!

cc @maralorn

maralorn commented 1 year ago

Interesting. I believe this is a general property of our builder, one would have to look into that to figure out if and how it could be avoided.

The recommended way to circumvent this problem is to install hls via the packages list of ghc with packages set. The toplevel hls package only has a very narrow use case.

deemp commented 1 year ago

@maralorn, what do you mean by via the packages list of ghc with packages set?

As you can see, here, I used pkgs.haskell.packages.ghc902 and got that strange behavior.

maralorn commented 1 year ago

@deemp I mean hpkgs.ghcWithPackages (ps: [ ps.acme-missiles ps.haskell-language-server]).

maralorn commented 1 year ago

That way you get hls exactly matching your ghc.