nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, fetchCrate, rustPlatform, clang, rustfmt
2, runtimeShell
3, bash
4}:
5let
6 # bindgen hardcodes rustfmt outputs that use nightly features
7 rustfmt-nightly = rustfmt.override { asNightly = true; };
8in rustPlatform.buildRustPackage rec {
9 pname = "rust-bindgen-unwrapped";
10 version = "0.65.1";
11
12 src = fetchCrate {
13 pname = "bindgen-cli";
14 inherit version;
15 sha256 = "9JJXQQSbCxTh3fIbVSrc6WAYGivwomkoB8ZIquUNr9o=";
16 };
17
18 cargoSha256 = "Kz6Y+4F9Yu5oKYI9LgZKLh0AkQTwerPS4A758TZrkoc=";
19
20 buildInputs = [ clang.cc.lib ];
21
22 preConfigure = ''
23 export LIBCLANG_PATH="${clang.cc.lib}/lib"
24 '';
25
26 doCheck = true;
27 nativeCheckInputs = [ clang ];
28
29 RUSTFMT = "${rustfmt-nightly}/bin/rustfmt";
30
31 preCheck = ''
32 # for the ci folder, notably
33 patchShebangs .
34 '';
35
36 passthru = { inherit clang; };
37
38 meta = with lib; {
39 description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
40 longDescription = ''
41 Bindgen takes a c or c++ header file and turns them into
42 rust ffi declarations.
43 '';
44 homepage = "https://github.com/rust-lang/rust-bindgen";
45 license = with licenses; [ bsd3 ];
46 maintainers = with maintainers; [ johntitor ralith ];
47 mainProgram = "bindgen";
48 platforms = platforms.unix;
49 };
50}