2023-10-09 19:29:22 +00:00
|
|
|
{ lib, stdenv, llvmPackages, enableLibcxx ? false }:
|
|
|
|
# enableLibcxx will use the c++ headers from clang instead of gcc.
|
|
|
|
# This shouldn't have any effect on platforms that use clang as the default compiler already.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-05-20 23:08:51 +00:00
|
|
|
unwrapped = llvmPackages.clang-unwrapped;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
2022-06-16 17:23:12 +00:00
|
|
|
inherit unwrapped;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "clang-tools";
|
2021-05-20 23:08:51 +00:00
|
|
|
version = lib.getVersion unwrapped;
|
2020-04-24 23:36:52 +00:00
|
|
|
dontUnpack = true;
|
2023-10-09 19:29:22 +00:00
|
|
|
clang = if enableLibcxx then llvmPackages.libcxxClang else llvmPackages.clang;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
for tool in $unwrapped/bin/clang-*; do
|
|
|
|
tool=$(basename "$tool")
|
|
|
|
|
|
|
|
# Compilers have their own derivation, no need to include them here:
|
|
|
|
if [[ $tool == "clang-cl" || $tool == "clang-cpp" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clang's derivation produces a lot of binaries, but the tools we are
|
|
|
|
# interested in follow the `clang-something` naming convention - except
|
|
|
|
# for clang-$version (e.g. clang-13), which is the compiler again:
|
|
|
|
if [[ ! $tool =~ ^clang\-[a-zA-Z_\-]+$ ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s $out/bin/clangd $out/bin/$tool
|
|
|
|
done
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
if [[ -z "$(ls -A $out/bin)" ]]; then
|
|
|
|
echo "Found no binaries - maybe their location or naming convention changed?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
substituteAll ${./wrapper} $out/bin/clangd
|
|
|
|
chmod +x $out/bin/clangd
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
meta = unwrapped.meta // {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Standalone command line tools for C++ development";
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with lib.maintainers; [ patryk27 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|