1{
2 fetchzip,
3 lib,
4 stdenvNoCC,
5 copyDesktopItems,
6 imagemagick,
7 makeDesktopItem,
8 jre,
9}:
10let
11 vPath = v: lib.elemAt (lib.splitString "-" v) 0;
12
13 version = "2025.3-b151";
14
15 arches = {
16 aarch64-linux = "arm64";
17 x86_64-linux = "x64";
18 };
19
20 arch = arches.${stdenvNoCC.targetPlatform.system} or (throw "Unsupported system");
21
22 hashes = {
23 arm64 = "sha256-pQ/AC50Ck7jVw5FTWgj8arDej0b0YXlEZ/vT43GWGoM=";
24 x64 = "sha256-mgiry7nGe7Ct1sXsztits2X2XJBj4kUBzjVRQQMLCyE=";
25 };
26
27 desktopItem = makeDesktopItem {
28 name = "YourKit Java Profiler";
29 desktopName = "YourKit Java Profiler " + version;
30 type = "Application";
31 exec = "yourkit-java-profiler %f";
32 icon = "yourkit-java-profiler";
33 categories = [
34 "Development"
35 "Java"
36 "Profiling"
37 ];
38 terminal = false;
39 startupWMClass = "YourKit Java Profiler";
40 };
41in
42stdenvNoCC.mkDerivation {
43 inherit version;
44
45 pname = "yourkit-java";
46
47 src = fetchzip {
48 url = "https://download.yourkit.com/yjp/${vPath version}/YourKit-JavaProfiler-${version}-${arch}.zip";
49 hash = hashes.${arch};
50 };
51
52 nativeBuildInputs = [
53 copyDesktopItems
54 imagemagick
55 ];
56
57 buildInputs = [ jre ];
58
59 desktopItems = [ desktopItem ];
60
61 installPhase = ''
62 runHook preInstall
63
64 mkdir -p $out
65 cp -pr bin lib license.html license-redist.txt probes samples $out
66 cp ${./forbid-desktop-item-creation} $out/bin/forbid-desktop-item-creation
67 mv $out/bin/profiler.sh $out/bin/yourkit-java-profiler
68 mkdir -p $out/share/icons
69 convert $out/bin/profiler.ico\[0] \
70 -size 256x256 \
71 $out/share/icons/yourkit-java-profiler.png
72 rm $out/bin/profiler.ico
73 rm -rf $out/bin/{windows-*,mac,linux-{*-32,musl-*,ppc-*}}
74 if [[ ${arch} = x64 ]]; then
75 rm -rf $out/bin/linux-arm-64
76 else
77 rm -rf $out/bin/linux-x86-64
78 fi
79 substituteInPlace $out/bin/yourkit-java-profiler \
80 --replace 'JAVA_EXE="$YD/jre64/bin/java"' JAVA_EXE=${jre}/bin/java
81 # Use our desktop item, which will be purged when this package
82 # gets removed
83 sed -i -e "/^YD=/isource $out/bin/forbid-desktop-item-creation\\
84 " \
85 $out/bin/yourkit-java-profiler
86
87 runHook postInstall
88 '';
89
90 passthru.updateScript = ./update.sh;
91
92 meta = with lib; {
93 description = "Award winning, fully featured low overhead profiler for Java EE and Java SE platforms";
94 homepage = "https://www.yourkit.com";
95 changelog = "https://www.yourkit.com/changes/";
96 license = licenses.unfree;
97 mainProgram = "yourkit-java-profiler";
98 platforms = attrNames arches;
99 sourceProvenance = with sourceTypes; [ binaryBytecode ];
100 maintainers = with maintainers; [ herberteuler ];
101 };
102}