Change:
mime-string = disableOptimization super.mime-string; # Older compilers need the latest ghc-lib to build this package. <del> hls-hlint-plugin = addBuildDepend self.ghc-lib (overrideCabal (drv: { # Workaround for https://github.com/haskell/haskell-language-server/issues/2728 postPatch = '' sed -i 's/(GHC.RealSrcSpan x,/(GHC.RealSrcSpan x Nothing,/' src/Ide/Plugin/Hlint.hs ''; }) super.hls-hlint-plugin); </del> <ins> # Fix build with ghc-lib >= 9.0 and ghc <= 8.10.7 # https://github.com/haskell/haskell-language-server/issues/2728 hls-hlint-plugin = addBuildDepend self.ghc-lib (appendPatch (pkgs.fetchpatch { name = "hls-hlint-plugin-workaround.patch"; url = "https://github.com/haskell/haskell-language-server/pull/2854.patch"; hash = "sha256-bLGu0OQtXsmMF3rZM+R6k7bsZm4Vgf2r0ert5Wunong="; stripLen = 2; includes = ["src/Ide/Plugin/Hlint.hs"]; }) super.hls-hlint-plugin); </ins> haskell-language-server = appendConfigureFlags [ "-f-stylishhaskell"

Discussion:
The core of haskell-language-server works, and it finds Cabal and GHC in a Nix shell, however HLint and other plugins like formatting providers don't work. I think I'm using the correct HLS package per this . My nixpkgs everywhere that follows is recent "unstable". Steps to reproduce the behavior: globally or via Home Manager. Hook up a LSP-capable editor. into a Haskell project and enter this Nix shell: the project building, add the following code: HLS should report a HLint warning, like it does if you run : With a formatting provider configured such as stylish-haskell, HLS reports: HLS seems able to find stuff in the Nix shell environment: I've recently migrated from Arch to NixOS with the same editor (Neovim) config. On Arch with GHCup both HLint and stylish-haskell worked. I'm convinced this isn't an editor issue because HLint previously worked without any reference to it in my editor config. Best guess based upon recent activity:
They were disabled in which I think was because they were disabled by default for 9.0.1 (as those plugins don't support GHC 9.0.1), so wouldn't provide their dependencies. I think it should still be possible to re-enable them if we provide the necessary dependencies via . Seems like this was done because of this problem: ; Probably not impossible to work around though?
I don't know the deails, but this is a good summar of what hls should support: https://haskell-language-
Hey there. Sorry, I was on a short vacation. Yes, it is correct that some plugins are currently disabled on ghc 8.10.7. The list can be found in : For every of those plugins there was a specific reason that it was hard to build on ghc 8.10.7. I don’t know how much work it will be to get them running, because this is apparently a combination of ghc version and dependency versions, which upstream never tested with. Let’s keep this issue open to track if we can fix some of them.
I have pushed onto the haskell-updates branch.
I have also fixed .
stylish-haskell and brittany are tougher nuts to crack, sorry.

An old enough brittany for ghc 8.10 needs aeson < 2.0 which is a major undertaking to get done. For stylish-haskell we need to find an older version and a compatible old ghc-lib to get it to work with the old Cabal we use on ghc 8.10 …
Can we enable stylish-haskell conditionally on ghc-9, where it seems to be available?
Not at the moment it seems, HLS only supports it for GHC < 9:
I was unable to get the and plugins working even with fixes. I tried making a dev shell with this flake: (I've also tried the branch which should have the fixes merged now.) Am I doing something wrong?
Can you explain what you mean with "working"? That shell looks about right. Also when I install haskell-language-server for that ghc version on nixos-unstable it pulls in the fourmolu and the hlint plugin, so they should be working.
I'm getting the same behavior as in OP: no hlint hints and trying to format code gives the error .
Huh, that’s unfortunate. So turns out: My hlint patch made the hlint plugin compile, but not actually work: but when I test this I actually see that error message in my editor: ! I had asked upstream for help as to how to fix this, but haven’t gotten a reaction: Besides that formatting with fourmolu seems to work for me. If you don‘t get the above error message when you have something which should trigger hlint in your could then I guess there is an issue in your setup?
Yesterday I got HLS 8.10.7 working with nix on an M1 Mac and see the same error about a non exhaustive pattern match. Happy to test or try to fix something upstream in HLS since I'd like to contribute more there
Let’s continue here, because this now definitely a downstream problem. I have been told that the monthly hls releases aren‘t a thing anymore, so the wait could probably be longer than I anticipated. Pulling in the patch into nixpkgs is not super trivial depending on your experience, but I will gladly help and am reachable in on matrix.

The way to go would be this: go the pkgs/development/haskell-modules/configuration-ghc- file and search the hls-hlint-plugin override. Remove my overrideCabal call for the misguided sed based patch and instead do a appendPatch + fetchpatch combo for the PR from hls repo as for example seen a few lines earlier in the same file. You will need the option to fetchpatch to restrict it to the hls-hlint-plugin patch. Don‘t hesitate to ask if anything is unclear.
do you mind sharing the instructions to get it to build on here?
PR doing this is up at , can you please test and report back there?
I think this can be closed with I successfully checked with nix shell And I am using in projects, and all is working well! I can not say anything about nor .