nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchCrate,
4 rustPlatform,
5 clang,
6 rustfmt,
7}:
8let
9 # bindgen hardcodes rustfmt outputs that use nightly features
10 rustfmt-nightly = rustfmt.override { asNightly = true; };
11in
12rustPlatform.buildRustPackage rec {
13 pname = "rust-bindgen-unwrapped";
14 version = "0.72.1";
15
16 src = fetchCrate {
17 pname = "bindgen-cli";
18 inherit version;
19 hash = "sha256-rhdQZcnlqVSUqvFDg0Scs1+DHGcKyazeS5H9HH7u8Fk=";
20 };
21
22 cargoHash = "sha256-YNpqVB+zdZ76Av2L+yQuBrxKvNML9+3H7ES4+7mED0E=";
23
24 preConfigure = ''
25 export LIBCLANG_PATH="${lib.getLib clang.cc}/lib"
26 '';
27
28 # Disable the "runtime" feature, so libclang is linked.
29 buildNoDefaultFeatures = true;
30 buildFeatures = [ "logging" ];
31 checkNoDefaultFeatures = buildNoDefaultFeatures;
32 checkFeatures = buildFeatures;
33
34 doCheck = true;
35 nativeCheckInputs = [ clang ];
36
37 RUSTFMT = "${rustfmt-nightly}/bin/rustfmt";
38
39 preCheck = ''
40 # for the ci folder, notably
41 patchShebangs .
42 '';
43
44 passthru = { inherit clang; };
45
46 meta = {
47 description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
48 longDescription = ''
49 Bindgen takes a c or c++ header file and turns them into
50 rust ffi declarations.
51 '';
52 homepage = "https://github.com/rust-lang/rust-bindgen";
53 license = with lib.licenses; [ bsd3 ];
54 maintainers = with lib.maintainers; [ johntitor ];
55 mainProgram = "bindgen";
56 platforms = lib.platforms.unix;
57 };
58}