about summary refs log tree commit diff
path: root/pkgs/development/libraries/tezos-rust-libs/default.nix
blob: 85470f606f28e1ccce7764b900cb2d2797cbd15c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, fetchFromGitLab, stdenv, llvmPackages_12, cargo, libiconv }:

stdenv.mkDerivation rec {
  version = "1.5";
  pname = "tezos-rust-libs";
  src = fetchFromGitLab {
    owner = "tezos";
    repo = "tezos-rust-libs";
    rev = "v${version}";
    hash = "sha256-SuCqDZDXmWdGI/GN+3nYcUk66jnW5FQQaeTB76/rvaw=";
  };

  nativeBuildInputs = [ llvmPackages_12.llvm cargo ];
  propagatedBuildDeps = [ llvmPackages_12.libllvm ];
  buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];

  buildPhase = ''
    runHook preBuild

    cargo build \
      --target-dir target-librustzcash \
      --package librustzcash \
      --release

    cargo build \
      --target-dir target-wasmer \
      --package wasmer-c-api \
      --no-default-features \
      --features singlepass,cranelift,wat,middlewares,universal \
      --release

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib/tezos-rust-libs/rust
    cp "librustzcash/include/librustzcash.h" \
        "target-librustzcash/release/librustzcash.a" \
        "wasmer-2.3.0/lib/c-api/wasm.h" \
        "wasmer-2.3.0/lib/c-api/wasmer.h" \
        "target-wasmer/release/libwasmer.a" \
        "$out/lib/tezos-rust-libs"
    cp -r "librustzcash/include/rust" "$out/lib/tezos-rust-libs"

    runHook postInstall
  '';

  cargoVendorDir = "./vendor";
}