Help with config syntax

I want to install haskell-language-server for ghc 9.6.7. The packages search says this:

This package provides the executables haskell-language-server-9.10.3 and haskell-language-server-wrapper. You can choose for which ghc versions to install hls with pkgs.haskell-language-server.override { supportedGhcVersions = [ “90” “92” ]; }.

This (partial) configuration.nix (I have tried lots)

pkgs.haskell-language-server.override = {
  supportedGhcVersions = [ "94" "96" ];
};

environment.systemPackages = with pkgs; [
    vivaldi
    vscodium
    git
    gcc
    pkg-config
    gparted
    haskell.compiler.native-bignum.ghc96
    haskell-language-server
    haskellPackages.cabal-install
  ];

makes nixos-rebuild switch say

 error: The option `pkgs' does not exist. Definition values:
       - In `/etc/nixos/configuration.nix':
           {
             haskell-language-server = {
               override = {
                 supportedGhcVersions = [
                   "94"
           ...

What do I actually have to put?

Compilers don’t go in your config. Get that gcc and haskell out of your environment.systemPackages. Use development shells. Declarative shell environments with shell.nix — nix.dev documentation

You could then write in said shell.nix:

#...
pkgs.mkShell {
  packages = [
    (pkgs.haskell-language-server.override { supportedGhcVersions = [ "94" "96" ]; })
    pkgs.haskell.compiler.native-bignum.ghc96
  ];
}

(gcc is not necessary, that comes for free with mkShell.)

.override is a function that you want to call, not an attribute that you want to assign to. See Nix language basics — nix.dev documentation. And this expression results in a package, so the package has to go in a package list (like the packages arg to mkShell, in this case).

1 Like

Thank you. Well I made a shell.nix

#...
{
  pkgs ? import <nixpkgs> { },
}:
pkgs.mkShell {
  packages = [
    (pkgs.haskell-language-server.override { supportedGhcVersions = [ "96" ]; })
    pkgs.haskell.compiler.native-bignum.ghc96
  ];
}

It built haskell-language-server. So I loaded up codium. I had to set it to use $PATH to find haskell-language-server since GHCup doesn’t work on NixOS. codium gave me this error, though

2026-01-29 19:33:02.7660000 [client] INFO Finding haskell-language-server
2026-01-29 19:33:02.7670000 [client] INFO Searching for server executables haskell-language-server-wrapper,haskell-language-server in $PATH
2026-01-29 19:33:02.7670000 [client] INFO $PATH environment variable: /nix/store/sppmi7xjnhys3f1v2mvivx395ks71vjg-glib-2.86.3-bin/bin:/nix/store/737jwbhw8ji13x9s88z3wpp8pxaqla92-gnugrep-3.12/bin:/nix/store/iiishysy5bzkjrawxl4rld1s04qj0k0c-coreutils-9.8/bin:/nix/store/f43k3lffqlz3n864inxz8zf28jvks1q6-bash-interactive-5.3p3/bin:/nix/store/dqyvfskvbnry1ycxnpishvsyk3rfva64-haskell-language-server-2.12.0.0/bin:/nix/store/sr1wdhrwnvd1pbfgydwgk7z25ghbpznx-ghc-native-bignum-9.6.7/bin:/nix/store/axrdk0z4gwqv9kpql2lgqq42l37m3yd1-patchelf-0.15.2/bin:/nix/store/myvv172x2am72534zgn9wx0qp5amq6a8-gcc-wrapper-14.3.0/bin:/nix/store/m1k4nxs8r0fl0pjxqp5n37vxgms7gdlb-gcc-14.3.0/bin:/nix/store/ijmp8r14ivvzk5r95lwx49bbv089003g-glibc-2.40-66-bin/bin:/nix/store/4dh4138m8gbp56kh63j2pwgsfhf5l8v7-binutils-wrapper-2.44/bin:/nix/store/v9zpzmigqkcjrw1jpf0zjc49y47cm55s-binutils-2.44/bin:/nix/store/kpi3v5fl8hlgy5lagjvn6ayq78mla49k-ncurses-6.5/bin:/nix/store/n8f6dc226f3z0yz8b7yh2ksi5gx70mha-numactl-2.0.18/bin:/nix/store/iiishysy5bzkjrawxl4rld1s04qj0k0c-coreutils-9.8/bin:/nix/store/6hcyzg88adcz37hn5pslwb06ck6pnq07-findutils-4.10.0/bin:/nix/store/7ylvy12ylwy8wxya9i2ly8qkhiz7173r-diffutils-3.12/bin:/nix/store/rm3yhwgahfrmshmcrv6cr28x4rz7881s-gnused-4.9/bin:/nix/store/gh0ijwnyv6csn59yars8z8kxbnd31y8f-gawk-5.3.2/bin:/nix/store/l5ibq1yp8m7jibzgqbmpc46hkcnvv8fq-gnutar-1.35/bin:/nix/store/0hq8fc3ihp7clficpl72lxybfb23qvfc-gzip-1.14/bin:/nix/store/2xq4b1wjl6yklsqs86mf95lg9j8mbxvl-bzip2-1.0.8-bin/bin:/nix/store/bw02qy5hlr6a12p5f2apkk79204n20yh-gnumake-4.4.1/bin:/nix/store/j8645yndikbrvn292zgvyv64xrrmwdcb-bash-5.3p3/bin:/nix/store/mv1hg02434l28cf4vwg4qbrz2h967ms8-patch-2.8/bin:/nix/store/gq3243j1d8y6qgpcrgbbb0vxkbxzs0ix-xz-5.8.1-bin/bin:/nix/store/30k6wlj854gb3rw7ny2rj3fixn8xrx6p-file-5.45/bin:/run/wrappers/bin:/home/brett/.nix-profile/bin:/nix/profile/bin:/home/brett/.local/state/nix/profile/bin:/etc/profiles/per-user/brett/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
2026-01-29 19:33:02.7740000 [client] INFO Found server executable in $PATH: haskell-language-server-wrapper
2026-01-29 19:33:02.7740000 [client] INFO Support for '.cabal' files: automatic
2026-01-29 19:33:02.7740000 [client] INFO Activating the language server in working dir: /home/brett/swissarmyknife (the workspace folder)
2026-01-29 19:33:02.7740000 [client] INFO run command: haskell-language-server-wrapper --lsp
2026-01-29 19:33:02.7750000 [client] INFO debug command: haskell-language-server-wrapper --lsp
2026-01-29 19:33:02.7750000 [client] INFO server cwd: /home/brett/swissarmyknife
2026-01-29 19:33:02.7750000 [client] INFO server environment variables:
2026-01-29 19:33:02.7750000 [client] INFO Executing 'haskell-language-server-wrapper --numeric-version' in cwd '/home/brett/swissarmyknife'
2026-01-29 19:33:03.2670000 [client] INFO Starting language server
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.12.0.0 x86_64 ghc-9.6.7
Current directory: /home/brett/swissarmyknife
Operating system: linux
Arguments: ["--lsp"]
Cradle directory: /home/brett/swissarmyknife
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.16.0.0
stack:          Not found
ghc:            9.6.7


Consulting the cradle to get project GHC version...
2026-01-29T19:33:03.810232Z | Debug | cabal --numeric-version
2026-01-29T19:33:03.906977Z | Debug | cabal path --output-format=json
2026-01-29T19:33:03.970131Z | Debug | /nix/store/sr1wdhrwnvd1pbfgydwgk7z25ghbpznx-ghc-native-bignum-9.6.7/bin/ghc --numeric-version
Project GHC version: 9.6.7
haskell-language-server exe candidates: ["haskell-language-server-9.6.7","haskell-language-server"]
Launching haskell-language-server exe at:/nix/store/dqyvfskvbnry1ycxnpishvsyk3rfva64-haskell-language-server-2.12.0.0/bin/haskell-language-server-9.6.7
2026-01-29T19:33:04.042026Z | Debug | cabal path --output-format=json
2026-01-29T19:33:05.226289Z | Debug | /nix/store/sr1wdhrwnvd1pbfgydwgk7z25ghbpznx-ghc-native-bignum-9.6.7/bin/ghc -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2026-01-29T19:33:05.306165Z | Debug | cabal path --output-format=json
2026-01-29T19:33:05.368740Z | Debug | /nix/store/sr1wdhrwnvd1pbfgydwgk7z25ghbpznx-ghc-native-bignum-9.6.7/bin/ghc --print-libdir
e[0;31mGHC ABIs don't match!e[0m
e[0;31me[0m
e[0;31mExpected: ghc-9.6.7:370141a5e817aeddf7da698e00e5273b template-haskell-2.20.0.0:b95d53dda21b28ef36a60c43f7bb05b7e[0m
e[0;31mGot:      ghc-9.6.7:4e269cbba429d0e255849bf0f51055db template-haskell-2.20.0.0:bf94a31b91a2f780a40828337e734bdfe[0m
[Error - 19:33:05] Client Haskell (swissarmyknife): connection to server is erroring.
Unterminated string in JSON at position 203 (line 1 column 204)
Shutting down server.
[Error - 19:33:05] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
	at D.shutdown (/home/brett/.vscode-oss/extensions/haskell.haskell-2.6.1-universal/dist/extension.js:1:353372)
	at D.stop (/home/brett/.vscode-oss/extensions/haskell.haskell-2.6.1-universal/dist/extension.js:1:352953)
	at D.stop (/home/brett/.vscode-oss/extensions/haskell.haskell-2.6.1-universal/dist/extension.js:1:2168)
	at D.handleConnectionError (/home/brett/.vscode-oss/extensions/haskell.haskell-2.6.1-universal/dist/extension.js:1:359472)
[Error - 19:33:05] Server process exited with code 1.
[Error - 19:33:05] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 19:33:05] Connection to server got closed. Server will restart.
true
[Error - 19:33:05] Haskell (swissarmyknife) client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097