Skip to content

Commit 26cd856

Browse files
authored
besu: use jemalloc if possible (nix-community#511)
* besu: use jemalloc if possible * besu: add aarch64-darwin as supported platform
1 parent 31fa0d6 commit 26cd856

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

pkgs/besu/default.nix

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
fetchurl,
3+
jemalloc,
34
jre,
45
lib,
56
makeWrapper,
7+
runCommand,
68
stdenv,
9+
testers,
710
}:
8-
stdenv.mkDerivation rec {
11+
stdenv.mkDerivation (finalAttrs: rec {
912
pname = "besu";
1013
version = "24.3.3";
1114

@@ -14,22 +17,44 @@ stdenv.mkDerivation rec {
1417
hash = "sha256-ua7lGVIYf/VQ3kgfLAQFE3uF8dCqOCYWDfbX5QXzWa4=";
1518
};
1619

20+
buildInputs = lib.optionals stdenv.isLinux [jemalloc];
1721
nativeBuildInputs = [makeWrapper];
1822

1923
installPhase = ''
2024
mkdir -p $out/bin
2125
cp -r bin $out/
2226
mkdir -p $out/lib
2327
cp -r lib $out/
24-
wrapProgram $out/bin/${pname} --set JAVA_HOME "${jre}"
28+
wrapProgram $out/bin/${pname} --set JAVA_HOME "${jre}" --suffix ${
29+
if stdenv.isDarwin
30+
then "DYLD_LIBRARY_PATH"
31+
else "LD_LIBRARY_PATH"
32+
} : ${lib.makeLibraryPath buildInputs}
2533
'';
2634

35+
passthru.tests = {
36+
version = testers.testVersion {
37+
package = finalAttrs.finalPackage;
38+
version = "v${version}";
39+
};
40+
jemalloc =
41+
runCommand "${pname}-test-jemalloc"
42+
{
43+
nativeBuildInputs = [finalAttrs.finalPackage];
44+
meta.platforms = with lib.platforms; linux;
45+
} ''
46+
# Expect to find this string in the output, ignore other failures.
47+
(besu 2>&1 || true) | grep -q "# jemalloc: ${jemalloc.version}"
48+
mkdir $out
49+
'';
50+
};
51+
2752
meta = with lib; {
2853
description = "Besu is an Apache 2.0 licensed, MainNet compatible, Ethereum client written in Java";
2954
homepage = "https://github.com/hyperledger/besu";
3055
license = licenses.asl20;
3156
mainProgram = "besu";
32-
platforms = ["x86_64-linux"];
57+
platforms = ["aarch64-darwin" "x86_64-linux"];
3358
sourceProvenance = with sourceTypes; [binaryBytecode];
3459
};
35-
}
60+
})

0 commit comments

Comments
 (0)