Skip to content

Commit ea7f37d

Browse files
committed
try fixing hermes build in ci
1 parent bb4a596 commit ea7f37d

File tree

2 files changed

+93
-70
lines changed

2 files changed

+93
-70
lines changed

nix/default.nix

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,28 @@ import sources.nixpkgs {
6262
};
6363
})
6464
(_: pkgs: {
65-
hermes =
66-
let
65+
hermes = pkgs.callPackage ./hermes.nix { };
66+
# let
6767
# The informalsystems/hermes v1.13.1 requires rust version >= v1.83
6868
# The nixpkgs 24.11 is using rust version v1.82
6969
# 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-
};
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+
# };
8787
})
8888
(_: pkgs: { test-env = pkgs.callPackage ./testenv.nix { }; })
8989
(_: pkgs: { cosmovisor = pkgs.callPackage ./cosmovisor.nix { }; })

nix/hermes.nix

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,83 @@
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
11-
llvm,
12-
llvmPackages,
2+
lib
3+
, stdenv
4+
, fetchurl
5+
, makeWrapper
6+
, openssl
7+
, pkg-config
8+
, darwin
9+
, qemu
1310
}:
14-
rustPlatform.buildRustPackage rec {
15-
name = "hermes";
16-
inherit src;
17-
cargoBuildFlags = "-p ibc-relayer-cli";
18-
buildInputs = (lib.optionals stdenv.isDarwin [
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+
46+
buildInputs = lib.optionals stdenv.isDarwin [
1947
darwin.apple_sdk.frameworks.Security
20-
pkg-config
21-
openssl
2248
darwin.libiconv
2349
darwin.apple_sdk.frameworks.SystemConfiguration
24-
protobuf
25-
llvm
26-
llvmPackages.libclang
27-
llvmPackages.clang
28-
]) ++ (lib.optionals (!stdenv.isDarwin) [
29-
pkg-config
30-
openssl
31-
protobuf
32-
llvm
33-
llvmPackages.libclang
34-
llvmPackages.clang
35-
]);
36-
nativeBuildInputs = with llvmPackages; [
37-
clang
38-
libclang
3950
];
40-
cargoLock = {
41-
lockFile = "${src}/Cargo.lock";
42-
};
43-
doCheck = false;
44-
RUSTFLAGS = "--cfg ossl111 --cfg ossl110 --cfg ossl101";
45-
OPENSSL_NO_VENDOR = "1";
46-
OPENSSL_DIR = symlinkJoin {
47-
name = "openssl";
48-
paths = with openssl; [
49-
out
50-
dev
51-
];
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 ''
70+
wrapProgram $out/bin/hermes \
71+
${lib.optionalString stdenv.isLinux "LD_LIBRARY_PATH=${lib.makeLibraryPath [ openssl ]}"}
72+
''}
73+
'';
74+
75+
meta = with lib; {
76+
description = "An IBC Relayer written in Rust";
77+
homepage = "https://hermes.informal.systems/";
78+
license = licenses.asl20;
79+
platforms = platforms.unix;
80+
maintainers = with maintainers; [ ];
5281
};
53-
PROTOC = "${protobuf}/bin/protoc";
54-
PROTOC_INCLUDE = "${protobuf}/include";
55-
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
56-
CC = "${llvmPackages.clang}/bin/clang";
57-
CXX = "${llvmPackages.clang}/bin/clang++";
5882

59-
GIT_LFS_SKIP_SMUDGE = "1";
6083
}

0 commit comments

Comments
 (0)