about summary refs log tree commit diff
path: root/pkgs/applications/blockchains/besu/default.nix
blob: ef985a2806b7b9bcd9c072bfc695120843ff285e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ lib, stdenv, fetchurl, makeWrapper, jemalloc, jre, runCommand, testers }:

stdenv.mkDerivation (finalAttrs: rec {
  pname = "besu";
  version = "24.1.2";

  src = fetchurl {
    url = "https://hyperledger.jfrog.io/artifactory/${pname}-binaries/${pname}/${version}/${pname}-${version}.tar.gz";
    sha256 = "sha256-CC24z0+2dSeqDddX5dJUs7SX9QJ8Iyh/nAp0pqdDvwg=";
  };

  buildInputs = lib.optionals stdenv.isLinux [ jemalloc ];
  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    mkdir -p $out/bin
    cp -r bin $out/
    mkdir -p $out/lib
    cp -r lib $out/
    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 = "Enterprise-grade Java-based, Apache 2.0 licensed Ethereum client";
    homepage = "https://www.hyperledger.org/projects/besu";
    license = licenses.asl20;
    sourceProvenance = with sourceTypes; [ binaryBytecode ];
    platforms = platforms.all;
    maintainers = with maintainers; [ mmahut ];
  };
})