Skip to content

Commit a3574a7

Browse files
committed
fix hermes building error in ci
1 parent 9fdc9c3 commit a3574a7

File tree

4 files changed

+81
-84
lines changed

4 files changed

+81
-84
lines changed

nix/default.nix

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,7 @@ import sources.nixpkgs {
6161
};
6262
};
6363
})
64-
(_: pkgs: {
65-
hermes =
66-
let
67-
# The informalsystems/hermes v1.13.1 requires rust version >= v1.83
68-
# The nixpkgs 24.11 is using rust version v1.82
69-
# Use fenix to select different rust toolchain version
70-
rustToolchain =
71-
(import sources.fenix {
72-
inherit system;
73-
}).fromToolchainFile
74-
{
75-
file = ./rust-toolchain.toml;
76-
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
77-
};
78-
fenixRustPlatform = pkgs.makeRustPlatform {
79-
cargo = rustToolchain;
80-
rustc = rustToolchain;
81-
};
82-
in
83-
pkgs.callPackage ./hermes.nix {
84-
src = sources.hermes;
85-
rustPlatform = fenixRustPlatform;
86-
};
87-
})
64+
(_: pkgs: { hermes = pkgs.callPackage ./hermes.nix { }; })
8865
(_: pkgs: { test-env = pkgs.callPackage ./testenv.nix { }; })
8966
(_: pkgs: { cosmovisor = pkgs.callPackage ./cosmovisor.nix { }; })
9067
(_: pkgs: {

nix/hermes.nix

Lines changed: 75 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,84 @@
11
{
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
1110
}:
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+
1646
buildInputs = lib.optionals stdenv.isDarwin [
1747
darwin.apple_sdk.frameworks.Security
18-
pkg-config
19-
openssl
2048
darwin.libiconv
2149
darwin.apple_sdk.frameworks.SystemConfiguration
22-
protobuf
2350
];
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; [ ];
3682
};
37-
PROTOC = "${protobuf}/bin/protoc";
38-
PROTOC_INCLUDE = "${protobuf}/include";
83+
3984
}

nix/rust-toolchain.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

nix/sources.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@
3636
"url": "https://github.com/dapphub/dapptools/archive/ba9fbcf95c01d247a30b26d7e064e8abdfba79db.tar.gz",
3737
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
3838
},
39-
"fenix": {
40-
"branch": "main",
41-
"description": "Rust toolchains and rust-analyzer nightly for Nix [maintainers=@figsoda, @winterqt, @zmitchell]",
42-
"homepage": "",
43-
"owner": "nix-community",
44-
"repo": "fenix",
45-
"rev": "8c0499eb59f1c2c07b3734c210480623e1fe90a1",
46-
"sha256": "071sakz1zwa9jkskf3fqlgf166ms7rysa674qarr61s1r89k324g",
47-
"type": "tarball",
48-
"url": "https://github.com/nix-community/fenix/archive/8c0499eb59f1c2c07b3734c210480623e1fe90a1.tar.gz",
49-
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
50-
},
5139
"flake-compat": {
5240
"branch": "master",
5341
"description": null,
@@ -85,16 +73,16 @@
8573
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
8674
},
8775
"hermes": {
88-
"branch": "",
76+
"branch": "main",
8977
"description": "Rust implementation of an Inter-Blockchain Communication (IBC) relayer",
9078
"homepage": "",
9179
"owner": "informalsystems",
9280
"repo": "hermes",
93-
"rev": "5e403dd5c72ecc2bc296af4ddb70eae98ad28c5d",
94-
"sha256": "186m5fp8y7l3clylkjdyxflbi16fij1k9k8gl9xkpz8wcm69n3bq",
95-
"tag": "v1.13.1",
81+
"rev": "9a071a9b1d3d5af92e62e5488e874e18aab56f3d",
82+
"sha256": "0wh5hcybirpw2vilqpd10jyxd59wh70xwzhfzlrl196b6l02gckq",
83+
"tag": "",
9684
"type": "tarball",
97-
"url": "https://github.com/informalsystems/hermes/archive/5e403dd5c72ecc2bc296af4ddb70eae98ad28c5d.tar.gz",
85+
"url": "https://github.com/informalsystems/hermes/archive/9a071a9b1d3d5af92e62e5488e874e18aab56f3d.tar.gz",
9886
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
9987
},
10088
"niv": {

0 commit comments

Comments
 (0)