aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix b/infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix
new file mode 100644
index 000000000000..0c476a58e3d8
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/tools/rust/bindgen/default.nix
@@ -0,0 +1,66 @@
+{ stdenv, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin,
+ runtimeShell }:
+
+rustPlatform.buildRustPackage rec {
+ pname = "rust-bindgen";
+ version = "0.54.1";
+
+ RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
+
+ src = fetchFromGitHub {
+ owner = "rust-lang";
+ repo = pname;
+ rev = "v${version}";
+ sha256 = "116np72w6agsi94xa1bdn6h7sa9gd522h358zlixk9xrhrx7yfn3";
+ };
+
+ cargoSha256 = "12a7bd2579jcnkss073v5w5w68fxwvhq6c6ndjy8vp78wg83qich";
+
+ libclang = llvmPackages.libclang.lib; #for substituteAll
+
+ buildInputs = [ libclang ];
+
+ propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
+
+ configurePhase = ''
+ export LIBCLANG_PATH="${libclang}/lib"
+ '';
+
+ postInstall = ''
+ mv $out/bin/{bindgen,.bindgen-wrapped};
+ substituteAll ${./wrapper.sh} $out/bin/bindgen
+ chmod +x $out/bin/bindgen
+ '';
+
+ doCheck = true;
+ checkInputs =
+ let fakeRustup = writeScriptBin "rustup" ''
+ #!${runtimeShell}
+ shift
+ shift
+ exec "$@"
+ '';
+ in [
+ rustfmt
+ fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
+ clang
+ ];
+ preCheck = ''
+ # for the ci folder, notably
+ patchShebangs .
+ '';
+
+ meta = with stdenv.lib; {
+ description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
+ longDescription = ''
+ Bindgen takes a c or c++ header file and turns them into
+ rust ffi declarations.
+ As with most compiler related software, this will only work
+ inside a nix-shell with the required libraries as buildInputs.
+ '';
+ homepage = "https://github.com/rust-lang/rust-bindgen";
+ license = with licenses; [ bsd3 ];
+ platforms = platforms.unix;
+ maintainers = with maintainers; [ johntitor ralith ];
+ };
+}