From 26cd8560197abed7c1ebc082a746ea8f275075fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rolf=20Schr=C3=B6der?= Date: Thu, 2 May 2024 17:13:46 +0200 Subject: [PATCH] besu: use jemalloc if possible (#511) * besu: use jemalloc if possible * besu: add aarch64-darwin as supported platform --- pkgs/besu/default.nix | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/pkgs/besu/default.nix b/pkgs/besu/default.nix index d37bcf18..b4d4404b 100644 --- a/pkgs/besu/default.nix +++ b/pkgs/besu/default.nix @@ -1,11 +1,14 @@ { fetchurl, + jemalloc, jre, lib, makeWrapper, + runCommand, stdenv, + testers, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: rec { pname = "besu"; version = "24.3.3"; @@ -14,6 +17,7 @@ stdenv.mkDerivation rec { hash = "sha256-ua7lGVIYf/VQ3kgfLAQFE3uF8dCqOCYWDfbX5QXzWa4="; }; + buildInputs = lib.optionals stdenv.isLinux [jemalloc]; nativeBuildInputs = [makeWrapper]; installPhase = '' @@ -21,15 +25,36 @@ stdenv.mkDerivation rec { cp -r bin $out/ mkdir -p $out/lib cp -r lib $out/ - wrapProgram $out/bin/${pname} --set JAVA_HOME "${jre}" + wrapProgram $out/bin/${pname} --set JAVA_HOME "${jre}" --suffix ${ + if stdenv.isDarwin + then "DYLD_LIBRARY_PATH" + else "LD_LIBRARY_PATH" + } : ${lib.makeLibraryPath buildInputs} ''; + passthru.tests = { + version = testers.testVersion { + package = finalAttrs.finalPackage; + version = "v${version}"; + }; + jemalloc = + runCommand "${pname}-test-jemalloc" + { + nativeBuildInputs = [finalAttrs.finalPackage]; + meta.platforms = with lib.platforms; linux; + } '' + # Expect to find this string in the output, ignore other failures. + (besu 2>&1 || true) | grep -q "# jemalloc: ${jemalloc.version}" + mkdir $out + ''; + }; + meta = with lib; { description = "Besu is an Apache 2.0 licensed, MainNet compatible, Ethereum client written in Java"; homepage = "https://github.com/hyperledger/besu"; license = licenses.asl20; mainProgram = "besu"; - platforms = ["x86_64-linux"]; + platforms = ["aarch64-darwin" "x86_64-linux"]; sourceProvenance = with sourceTypes; [binaryBytecode]; }; -} +})