1{ stdenv, fetchFromGitHub, rustPlatform, makeWrapper, llvmPackages }:
2
3# Future work: Automatically communicate NIX_CFLAGS_COMPILE to bindgen's tests and the bindgen executable itself.
4
5rustPlatform.buildRustPackage rec {
6 name = "rust-bindgen-${version}";
7 version = "0.32.1";
8
9 src = fetchFromGitHub {
10 owner = "rust-lang-nursery";
11 repo = "rust-bindgen";
12 rev = version;
13 sha256 = "15m1y468c7ixzxwx29wazag0i19a3bmzjp53np6b62sf9wfzbsfa";
14 };
15
16 nativeBuildInputs = [ makeWrapper ];
17 buildInputs = [ llvmPackages.clang-unwrapped ];
18
19 configurePhase = ''
20 export LIBCLANG_PATH="${llvmPackages.clang-unwrapped}/lib"
21 '';
22
23 postInstall = ''
24 wrapProgram $out/bin/bindgen --set LIBCLANG_PATH "${llvmPackages.clang-unwrapped}/lib"
25 '';
26
27 cargoSha256 = "01h0y5phdv3ab8mk2yxw8lgg9783pjjnjl4087iddqhqanlv600d";
28
29 doCheck = false; # A test fails because it can't find standard headers in NixOS
30
31 meta = with stdenv.lib; {
32 description = "C and C++ binding generator";
33 homepage = https://github.com/rust-lang-nursery/rust-bindgen;
34 license = with licenses; [ bsd3 ];
35 maintainers = [ maintainers.ralith ];
36 };
37}