1{ lib, stdenv, fetchFromGitHub, rustPlatform, python3Packages, Security }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "rust-cbindgen";
5 version = "0.24.3";
6
7 src = fetchFromGitHub {
8 owner = "eqrion";
9 repo = "cbindgen";
10 rev = "v${version}";
11 hash = "sha256-v5g6/ul6mJtzC4O4WlNopPtFUSbx2Jv79mZL72mucws=";
12 };
13
14 cargoSha256 = "sha256-j3/2cFjSDkx0TXCaxYSCLrBbAHrJfJ6hwBcXlDedwh8=";
15
16 buildInputs = lib.optional stdenv.isDarwin Security;
17
18 checkInputs = [
19 python3Packages.cython
20 ];
21
22 checkFlags = [
23 # Disable tests that require rust unstable features
24 # https://github.com/eqrion/cbindgen/issues/338
25 "--skip test_expand"
26 "--skip test_bitfield"
27 "--skip lib_default_uses_debug_build"
28 "--skip lib_explicit_debug_build"
29 "--skip lib_explicit_release_build"
30 ] ++ lib.optionals stdenv.isDarwin [
31 # WORKAROUND: test_body fails when using clang
32 # https://github.com/eqrion/cbindgen/issues/628
33 "--skip test_body"
34 ];
35
36 meta = with lib; {
37 description = "A project for generating C bindings from Rust code";
38 homepage = "https://github.com/eqrion/cbindgen";
39 license = licenses.mpl20;
40 maintainers = with maintainers; [ hexa ];
41 };
42}