From e8e045b1fc47a9bacdd750498b35cb0ef18024bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rolf=20Schr=C3=B6der?= Date: Mon, 27 May 2024 09:27:00 +0200 Subject: [PATCH] besu: use jemalloc (Linux) & add tests (#282523) --- .../applications/blockchains/besu/default.nix | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/blockchains/besu/default.nix b/pkgs/applications/blockchains/besu/default.nix index f599c44b5a62..d897cb0fe716 100644 --- a/pkgs/applications/blockchains/besu/default.nix +++ b/pkgs/applications/blockchains/besu/default.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchurl, makeWrapper, jre }: +{ lib, stdenv, fetchurl, makeWrapper, jemalloc, jre, runCommand, testers }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: rec { pname = "besu"; version = "24.1.2"; @@ -9,6 +9,7 @@ stdenv.mkDerivation rec { sha256 = "sha256-CC24z0+2dSeqDddX5dJUs7SX9QJ8Iyh/nAp0pqdDvwg="; }; + buildInputs = lib.optionals stdenv.isLinux [ jemalloc ]; nativeBuildInputs = [ makeWrapper ]; installPhase = '' @@ -16,9 +17,27 @@ 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 = "An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client"; homepage = "https://www.hyperledger.org/projects/besu"; @@ -27,4 +46,4 @@ stdenv.mkDerivation rec { platforms = platforms.all; maintainers = with maintainers; [ mmahut ]; }; -} +})