1 { lib, stdenv, llvmPackages, enableLibcxx ? false }:
2 # enableLibcxx will use the c++ headers from clang instead of gcc.
3 # This shouldn't have any effect on platforms that use clang as the default compiler already.
6 unwrapped = llvmPackages.clang-unwrapped;
8 in stdenv.mkDerivation {
11 pname = "clang-tools";
12 version = lib.getVersion unwrapped;
14 clang = if enableLibcxx then llvmPackages.libcxxClang else llvmPackages.clang;
21 for tool in $unwrapped/bin/clang-*; do
22 tool=$(basename "$tool")
24 # Compilers have their own derivation, no need to include them here:
25 if [[ $tool == "clang-cl" || $tool == "clang-cpp" ]]; then
29 # Clang's derivation produces a lot of binaries, but the tools we are
30 # interested in follow the `clang-something` naming convention - except
31 # for clang-$version (e.g. clang-13), which is the compiler again:
32 if [[ ! $tool =~ ^clang\-[a-zA-Z_\-]+$ ]]; then
36 ln -s $out/bin/clangd $out/bin/$tool
39 if [[ -z "$(ls -A $out/bin)" ]]; then
40 echo "Found no binaries - maybe their location or naming convention changed?"
44 substituteAll ${./wrapper} $out/bin/clangd
45 chmod +x $out/bin/clangd
50 meta = unwrapped.meta // {
51 description = "Standalone command line tools for C++ development";
52 maintainers = with lib.maintainers; [ patryk27 ];