nixpkgs/pkgs/development/tools/clang-tools/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.5 KiB
Nix
Raw Normal View History

{ 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.
let
unwrapped = llvmPackages.clang-unwrapped;
2018-11-15 05:18:49 +00:00
in stdenv.mkDerivation {
inherit unwrapped;
2018-11-15 05:18:49 +00:00
pname = "clang-tools";
version = lib.getVersion unwrapped;
2019-06-19 15:45:34 +00:00
dontUnpack = true;
clang = if enableLibcxx then llvmPackages.libcxxClang else llvmPackages.clang;
installPhase = ''
2018-11-15 05:18:49 +00:00
runHook preInstall
mkdir -p $out/bin
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
ln -s $out/bin/clangd $out/bin/$tool
done
2018-11-15 05:18:49 +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
2018-11-15 05:18:49 +00:00
runHook postInstall
'';
2018-11-15 05:18:49 +00:00
meta = unwrapped.meta // {
description = "Standalone command line tools for C++ development";
2021-12-01 20:38:11 +00:00
maintainers = with lib.maintainers; [ patryk27 ];
};
}