···1+{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt, writeTextFile
2+, runtimeShell
3+, bash
4+}:
5+6+rustPlatform.buildRustPackage rec {
7+ pname = "rust-bindgen-unwrapped";
8+ version = "0.59.2";
9+10+ RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
11+12+ src = fetchFromGitHub {
13+ owner = "rust-lang";
14+ repo = "rust-bindgen";
15+ rev = "v${version}";
16+ sha256 = "sha256-bJYdyf5uZgWe7fQ80/3QsRV0qyExYn6P9UET3tzwPFs=";
17+ };
18+19+ cargoSha256 = "sha256-RKZY5vf6CSFaKweuuNkeFF0ZXlSUibAkcL/YhkE0MoQ=";
20+21+ buildInputs = [ clang.cc.lib ];
22+23+ preConfigure = ''
24+ export LIBCLANG_PATH="${clang.cc.lib}/lib"
25+ '';
26+27+ doCheck = true;
28+ checkInputs =
29+ let fakeRustup = writeTextFile {
30+ name = "fake-rustup";
31+ executable = true;
32+ destination = "/bin/rustup";
33+ text = ''
34+ #!${runtimeShell}
35+ shift
36+ shift
37+ exec "$@"
38+ '';
39+ };
40+ in [
41+ rustfmt
42+ fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
43+ clang
44+ ];
45+ preCheck = ''
46+ # for the ci folder, notably
47+ patchShebangs .
48+ '';
49+50+ passthru = { inherit clang; };
51+52+ meta = with lib; {
53+ description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
54+ longDescription = ''
55+ Bindgen takes a c or c++ header file and turns them into
56+ rust ffi declarations.
57+ As with most compiler related software, this will only work
58+ inside a nix-shell with the required libraries as buildInputs.
59+ This version of bindgen is wrapped with the required compiler flags
60+ required to find the c and c++ standard libary of the input clang
61+ derivation.
62+ '';
63+ homepage = "https://github.com/rust-lang/rust-bindgen";
64+ license = with licenses; [ bsd3 ];
65+ platforms = platforms.unix;
66+ maintainers = with maintainers; [ johntitor ralith ];
67+ };
68+}
+1-1
pkgs/development/tools/rust/bindgen/wrapper.sh
···30export LIBCLANG_PATH="@libclang@/lib"
31# shellcheck disable=SC2086
32# cxxflags and NIX_CFLAGS_COMPILE should be word-split
33-exec -a "$0" @out@/bin/.bindgen-wrapped "$@" $sep $cxxflags @cincludes@ $NIX_CFLAGS_COMPILE
34# note that we add the flags after $@ which is incorrect. This is only for the sake
35# of simplicity.
36
···30export LIBCLANG_PATH="@libclang@/lib"
31# shellcheck disable=SC2086
32# cxxflags and NIX_CFLAGS_COMPILE should be word-split
33+exec -a "$0" @unwrapped@/bin/bindgen "$@" $sep $cxxflags @cincludes@ $NIX_CFLAGS_COMPILE
34# note that we add the flags after $@ which is incorrect. This is only for the sake
35# of simplicity.
36