1{ stdenv
2, lib
3, fetchurl
4, makeWrapper
5, makeDesktopItem
6, copyDesktopItems
7, _7zz
8, jdk
9}:
10
11let
12 inherit (stdenv.hostPlatform) system;
13 pname = "jprofiler";
14
15 version = "13.0.6";
16 nameApp = "JProfiler";
17
18 meta = with lib; {
19 description = "JProfiler's intuitive UI helps you resolve performance bottlenecks";
20 longDescription = ''
21 JProfiler's intuitive UI helps you resolve performance bottlenecks,
22 pin down memory leaks and understand threading issues.
23 '';
24 homepage = "https://www.ej-technologies.com/products/jprofiler/overview.html";
25 license = licenses.unfree;
26 maintainers = with maintainers; [ catap ];
27 };
28
29 src = if stdenv.isLinux then fetchurl {
30 url = "https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_${lib.replaceStrings ["."] ["_"] version}.tar.gz";
31 hash = "sha256-orjBSaC7NvKcak+RSEa9V05oL3EZIBnp7TyaX/8XFyg=";
32 } else fetchurl {
33 url = "https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_macos_${lib.replaceStrings ["."] ["_"] version}.dmg";
34 hash = "sha256-OI6NSPqYws5Rv25U5jIPzkyJtB8LF04qHB3NPR9XBWg=";
35 };
36
37 srcIcon = fetchurl {
38 url = "https://www.ej-technologies.com/assets/content/header-product-jprofiler@2x-24bc4d84bd2a4eb641a5c8531758ff7c.png";
39 hash = "sha256-XUmuqhnNv7mZ3Gb4A0HLSlfiJd5xbCExVsw3hmXHeVE=";
40 };
41
42 desktopItems = makeDesktopItem {
43 name = pname;
44 exec = pname;
45 icon = pname;
46 comment = meta.description;
47 desktopName = nameApp;
48 genericName = "Java Profiler Tool";
49 categories = [ "Development" ];
50 };
51
52 linux = stdenv.mkDerivation {
53 inherit pname version src desktopItems;
54
55 nativeBuildInputs = [ makeWrapper copyDesktopItems ];
56
57 installPhase = ''
58 runHook preInstall
59 cp -r . $out
60
61 rm -f $out/bin/updater
62 rm -rf $out/bin/linux-ppc*
63 rm -rf $out/bin/linux-armhf
64 rm -rf $out/bin/linux-musl*
65
66 for f in $(find $out/bin -type f -executable); do
67 wrapProgram $f --set JAVA_HOME "${jdk.home}"
68 done
69
70 install -Dm644 "${srcIcon}" \
71 "$out/share/icons/hicolor/scalable/apps/jprofiler.png"
72 runHook postInstall
73 '';
74
75 meta = meta // { platforms = lib.platforms.linux; };
76 };
77
78 darwin = stdenv.mkDerivation {
79 inherit pname version src;
80
81 nativeBuildInputs = [ makeWrapper _7zz ];
82
83 unpackPhase = ''
84 runHook preUnpack
85 7zz x $src -x!JProfiler/\[\]
86 runHook postUnpack
87 '';
88
89 sourceRoot = "${nameApp}";
90
91 installPhase = ''
92 runHook preInstall
93 mkdir -p $out/{Applications,bin}
94 cp -R ${nameApp}.app $out/Applications/
95 makeWrapper $out/Applications/${nameApp}.app/Contents/MacOS/JavaApplicationStub $out/bin/${pname}
96 runHook postInstall
97 '';
98
99 meta = meta // { platforms = lib.platforms.darwin; };
100 };
101in
102if stdenv.isDarwin then darwin else linux