So… i got at least include-what-you-use to work with the following frankenstein-trick that reuses the clang++ wrapper script to wrap iwyu.
{
include-what-you-use,
clangStdenv
}:
clangStdenv.mkDerivation {
name = "include-what-you-use-fix";
src = include-what-you-use;
phases = [ "installPhase" ];
installPhase = ''
mkdir $out/
cp -r $src/bin $out
chmod +w -R $out/bin
# copy the c++ wrapper and patch the last exec line to use iwyu
mv $out/bin/include-what-you-use $out/bin/.include-what-you-use
cp ${clangStdenv.cc}/bin/c++ $out/bin/include-what-you-use
sed -i "s;^exec[^\\]*;exec $out/bin/.include-what-you-use ;" $out/bin/include-what-you-use
# the python tool is hardcoded to the original iwyu, fix that too
sed -i "s;${include-what-you-use};$out;" $out/bin/iwyu_tool.py
'';
}
For my use case, this turned out to work pretty well.
Of course that does not work with clang-tidy… although i got that running by creating an “echo wrapper” of the clang++ wrapper, and a tiny python script that simply “fixes” all command lines in the compile_commands.json file. This of course still does not fix the cmake integration of clang-tidy