|
1 | 1 | {
|
2 |
| - src, |
3 |
| - lib, |
4 |
| - stdenv, |
5 |
| - darwin, |
6 |
| - rustPlatform, |
7 |
| - symlinkJoin, |
8 |
| - openssl, |
9 |
| - pkg-config, |
10 |
| - protobuf, # required by namada_tx crate |
| 2 | + lib |
| 3 | +, stdenv |
| 4 | +, fetchurl |
| 5 | +, makeWrapper |
| 6 | +, openssl |
| 7 | +, pkg-config |
| 8 | +, darwin |
| 9 | +, qemu |
11 | 10 | }:
|
12 |
| -rustPlatform.buildRustPackage rec { |
13 |
| - name = "hermes"; |
14 |
| - inherit src; |
15 |
| - cargoBuildFlags = "-p ibc-relayer-cli"; |
| 11 | + |
| 12 | +let |
| 13 | + version = "1.13.1"; |
| 14 | + |
| 15 | + platform = if stdenv.isDarwin then |
| 16 | + if stdenv.isAarch64 then "aarch64-apple-darwin" |
| 17 | + else "x86_64-apple-darwin" |
| 18 | + else if stdenv.isLinux then |
| 19 | + # for linux, always use the x86_64 version |
| 20 | + "x86_64-unknown-linux-gnu" |
| 21 | + else |
| 22 | + throw "Unsupported platform: ${stdenv.system}"; |
| 23 | + |
| 24 | + url = "https://github.com/informalsystems/hermes/releases/download/v${version}/hermes-v${version}-${platform}.tar.gz"; |
| 25 | + |
| 26 | + sha256 = if platform == "aarch64-apple-darwin" then |
| 27 | + "1j87ikp29008f6x1pcbp8bc77yfhf40sa13d6iliglsisrgsjcas" |
| 28 | + else if platform == "x86_64-apple-darwin" then |
| 29 | + "0f9m8g2xg9l3ghvj42kwa7yn6gr3ralylscmz5bs99qdd5hc8fbd" |
| 30 | + else if platform == "x86_64-unknown-linux-gnu" then |
| 31 | + "0a5anc32brrl390i1aiz3yaar1s9lh3s8r70liw3v7lgd5fnpzgg" |
| 32 | + else |
| 33 | + throw "Unsupported platform: ${stdenv.system}"; |
| 34 | + |
| 35 | +in |
| 36 | +stdenv.mkDerivation { |
| 37 | + pname = "hermes"; |
| 38 | + inherit version; |
| 39 | + |
| 40 | + src = fetchurl { |
| 41 | + inherit url sha256; |
| 42 | + }; |
| 43 | + |
| 44 | + nativeBuildInputs = [ makeWrapper ]; |
| 45 | + |
16 | 46 | buildInputs = lib.optionals stdenv.isDarwin [
|
17 | 47 | darwin.apple_sdk.frameworks.Security
|
18 |
| - pkg-config |
19 |
| - openssl |
20 | 48 | darwin.libiconv
|
21 | 49 | darwin.apple_sdk.frameworks.SystemConfiguration
|
22 |
| - protobuf |
23 | 50 | ];
|
24 |
| - cargoLock = { |
25 |
| - lockFile = "${src}/Cargo.lock"; |
26 |
| - }; |
27 |
| - doCheck = false; |
28 |
| - RUSTFLAGS = "--cfg ossl111 --cfg ossl110 --cfg ossl101"; |
29 |
| - OPENSSL_NO_VENDOR = "1"; |
30 |
| - OPENSSL_DIR = symlinkJoin { |
31 |
| - name = "openssl"; |
32 |
| - paths = with openssl; [ |
33 |
| - out |
34 |
| - dev |
35 |
| - ]; |
| 51 | + |
| 52 | + sourceRoot = "."; |
| 53 | + |
| 54 | + installPhase = '' |
| 55 | + mkdir -p $out/bin |
| 56 | + cp hermes $out/bin/ |
| 57 | + chmod +x $out/bin/hermes |
| 58 | + ''; |
| 59 | + |
| 60 | + postFixup = '' |
| 61 | + ${if (stdenv.isLinux && stdenv.isAarch64) then '' |
| 62 | + # for ARM64 uses qemu to simulate x86_64 |
| 63 | + mv $out/bin/hermes $out/bin/hermes.x86_64 |
| 64 | + cat > $out/bin/hermes << EOF |
| 65 | + #!/bin/sh |
| 66 | + exec ${qemu}/bin/qemu-x86_64 $out/bin/hermes.x86_64 "\$@" |
| 67 | + EOF |
| 68 | + chmod +x $out/bin/hermes |
| 69 | + '' else if stdenv.isLinux then '' |
| 70 | + wrapProgram $out/bin/hermes --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ openssl ]}" |
| 71 | + '' else '' |
| 72 | + wrapProgram $out/bin/hermes |
| 73 | + ''} |
| 74 | + ''; |
| 75 | + |
| 76 | + meta = with lib; { |
| 77 | + description = "An IBC Relayer written in Rust"; |
| 78 | + homepage = "https://hermes.informal.systems/"; |
| 79 | + license = licenses.asl20; |
| 80 | + platforms = platforms.unix; |
| 81 | + maintainers = with maintainers; [ ]; |
36 | 82 | };
|
37 |
| - PROTOC = "${protobuf}/bin/protoc"; |
38 |
| - PROTOC_INCLUDE = "${protobuf}/include"; |
| 83 | + |
39 | 84 | }
|
0 commit comments