Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeWrapper,
6 jemalloc,
7 jre,
8 runCommand,
9 testers,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "besu";
14 version = "24.1.2";
15
16 src = fetchurl {
17 url = "https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/${finalAttrs.version}/besu-${finalAttrs.version}.tar.gz";
18 sha256 = "sha256-CC24z0+2dSeqDddX5dJUs7SX9QJ8Iyh/nAp0pqdDvwg=";
19 };
20
21 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ jemalloc ];
22 nativeBuildInputs = [ makeWrapper ];
23
24 installPhase = ''
25 mkdir -p $out/bin
26 cp -r bin $out/
27 mkdir -p $out/lib
28 cp -r lib $out/
29 wrapProgram $out/bin/besu \
30 --set JAVA_HOME "${jre}" \
31 --suffix ${
32 if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"
33 } : ${lib.makeLibraryPath finalAttrs.buildInputs}
34 '';
35
36 passthru.tests = {
37 version = testers.testVersion {
38 package = finalAttrs.finalPackage;
39 version = "v${finalAttrs.version}";
40 };
41 jemalloc =
42 runCommand "besu-test-jemalloc"
43 {
44 nativeBuildInputs = [ finalAttrs.finalPackage ];
45 meta.platforms = with lib.platforms; linux;
46 }
47 ''
48 # Expect to find this string in the output, ignore other failures.
49 (besu 2>&1 || true) | grep -q "# jemalloc: ${jemalloc.version}"
50 mkdir $out
51 '';
52 };
53
54 meta = with lib; {
55 description = "Enterprise-grade Java-based, Apache 2.0 licensed Ethereum client";
56 homepage = "https://www.hyperledger.org/projects/besu";
57 changelog = "https://github.com/hyperledger/besu/blob/${finalAttrs.version}/CHANGELOG.md";
58 license = licenses.asl20;
59 sourceProvenance = with sourceTypes; [ binaryBytecode ];
60 platforms = platforms.all;
61 maintainers = with maintainers; [ mmahut ];
62 };
63})