This commit is contained in:
Curt Spark 2025-11-19 01:46:34 +00:00
commit e216b6b94d
5 changed files with 49 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.cache/
a.out

16
README.org Normal file
View File

@ -0,0 +1,16 @@
* NixOS C++ Dev Template
Having issues getting clangd to detect std header files despite clang++ and g++ having no issues. So this template/workaround solves this.
I assume this is due to some wrapper script nonsense.
As a workaround I use bear to generate the necessary paths/arguments to get clangd to pick these up.
#+BEGIN_SRC
bear -- clang++ main.cpp
#+END_SRC
In the generated compile_commands.json. There is a command for generating the main project but also a temporary object file.
I assume this is more weird wrapper stuff (Bear does not support nixos clang wrappers)
You need to move the cxx_isystem related flags as these are where the c++ stdlibs are kept. Also just rename them to isystem otherwise they dont work for whatever reason.

19
compile_commands.json Normal file
View File

@ -0,0 +1,19 @@
[
{
"arguments": [
"/run/current-system/sw/bin/clang++",
"-resource-dir",
"/nix/store/k2s6xfca52n25yb8b6f58i87kszp3m7g-clang-wrapper-21.1.2/resource-root",
"-idirafter",
"/nix/store/dqgfdpr53ldqmdfmginb1z6kzslkzsdl-glibc-2.40-66-dev/include",
"-isystem",
"/nix/store/68ndh04pl2hhhizsarvzwa9cnlp7zj3d-gcc-14.3.0/include/c++/14.3.0",
"-isystem",
"/nix/store/68ndh04pl2hhhizsarvzwa9cnlp7zj3d-gcc-14.3.0/include/c++/14.3.0/x86_64-unknown-linux-gnu",
"-c",
"main.cpp"
],
"directory": "/home/cspark/Projects/CPP/hello_world",
"file": "/home/cspark/Projects/CPP/hello_world/main.cpp"
}
]

5
main.cpp Normal file
View File

@ -0,0 +1,5 @@
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
}

7
run.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
rm a.out
clang++ main.cpp
./a.out