It took me quite a while to find out how to make Language Server Protocol working with C/C++ on NixOS. clangd couldn’t find any standard header files and complained that “pp file not found”.
The trick to make it working is adding clang-tools
to nativeBuildInputs
in shell.nix
.
To make clang compiling the programs on the command line without complaining about missing standard library header files, stdenv.mkDerivation
can be changed to clangStdenv.mkDerivation
in shell.nix
. This doesn’t seem to cause any problems with gcc, which can still be used normally.
This is not needed on every computer, apparently some package installed on one of my computers makes clangd in LSP working without any shell.nix
arrangements.
I think this is a software problem of category 2: Introducing a non-transparent configuration without any intelligible error messages or hints or easy-to-find documentation.
Leave a Reply