nix package: add wrapper from nixpkgs#clang-tools

This commit is contained in:
Pogobanane
2024-05-28 12:18:08 +00:00
parent aa62c4788c
commit 57a681a626
2 changed files with 40 additions and 0 deletions

View File

@@ -4,13 +4,20 @@
pkg-config,
installShellFiles,
libclang,
clang,
llvmPackages,
libllvm,
yaml-cpp,
enableLibcxx ? false,
}:
stdenv.mkDerivation {
name = "clang-uml";
src = ../..;
# variables for substituteAll
unwrapped = llvmPackages.clang-unwrapped;
clang = if enableLibcxx then llvmPackages.libcxxClang else llvmPackages.clang;
nativeBuildInputs = [
cmake
pkg-config
@@ -18,12 +25,14 @@ stdenv.mkDerivation {
];
buildInputs = [
clang
libclang
libllvm
yaml-cpp
];
postInstall = ''
substituteAll ${./wrapper} $out/bin/clang-uml-wrapped
installShellCompletion --bash $src/packaging/autocomplete/clang-uml
installShellCompletion --zsh $src/packaging/autocomplete/_clang-uml
'';

31
packaging/nix/wrapper Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
# This file is copied from https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/clang-tools/wrapper
# The clang-tools wrapper is commonly used together with the clang package on
# nix, because without the wrapper, clang tools fail to find stdlib includes on
# nix.
buildcpath() {
local path after
while (( $# )); do
case $1 in
-isystem)
shift
path=$path${path:+':'}$1
;;
-idirafter)
shift
after=$after${after:+':'}$1
;;
esac
shift
done
echo $path${after:+':'}$after
}
export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(<@clang@/nix-support/libcxx-cxxflags) \
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
exec -a "$0" @unwrapped@/bin/$(basename $0) "$@"