1{
2 fetchurl,
3 fontconfig,
4 freetype,
5 glib,
6 gsettings-desktop-schemas,
7 gtk3,
8 jdk17,
9 lib,
10 libX11,
11 libXrender,
12 libXtst,
13 makeDesktopItem,
14 makeWrapper,
15 shared-mime-info,
16 stdenv,
17 unzip,
18 webkitgtk_4_1,
19 zlib,
20}:
21
22let
23 pVersion = "1.15.0.20231206";
24 pVersionTriple = lib.splitVersion pVersion;
25 majorVersion = lib.elemAt pVersionTriple 0;
26 minorVersion = lib.elemAt pVersionTriple 1;
27 patchVersion = lib.elemAt pVersionTriple 2;
28 baseVersion = "${majorVersion}.${minorVersion}.${patchVersion}";
29 jdk = jdk17;
30in
31stdenv.mkDerivation rec {
32 pname = "eclipse-mat";
33 version = pVersion;
34
35 src = fetchurl {
36 url = "http://ftp.halifax.rwth-aachen.de/eclipse//mat/${baseVersion}/rcp/MemoryAnalyzer-${version}-linux.gtk.x86_64.zip";
37 sha256 = "sha256-icmo5zdK0XaH32kXwZUVaQ0VPSGEgvlLr7v7PtdbmCg=";
38 };
39
40 desktopItem = makeDesktopItem {
41 name = "eclipse-mat";
42 exec = "eclipse-mat";
43 icon = "eclipse";
44 comment = "Eclipse Memory Analyzer";
45 desktopName = "Eclipse MAT";
46 genericName = "Java Memory Analyzer";
47 categories = [ "Development" ];
48 };
49
50 unpackPhase = ''
51 unzip $src
52 '';
53
54 buildCommand = ''
55 mkdir -p $out
56 unzip $src
57 mv mat $out
58
59 # Patch binaries.
60 interpreter=$(echo ${stdenv.cc.libc}/lib/ld-linux*.so.2)
61 libCairo=$out/eclipse/libcairo-swt.so
62 patchelf --set-interpreter $interpreter $out/mat/MemoryAnalyzer
63 [ -f $libCairo ] && patchelf --set-rpath ${
64 lib.makeLibraryPath [
65 freetype
66 fontconfig
67 libX11
68 libXrender
69 zlib
70 ]
71 } $libCairo
72
73 # Create wrapper script. Pass -configuration to store settings in ~/.eclipse-mat/<version>
74 makeWrapper $out/mat/MemoryAnalyzer $out/bin/eclipse-mat \
75 --prefix PATH : ${jdk}/bin \
76 --prefix LD_LIBRARY_PATH : ${
77 lib.makeLibraryPath ([
78 glib
79 gtk3
80 libXtst
81 webkitgtk_4_1
82 ])
83 } \
84 --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
85 --add-flags "-configuration \$HOME/.eclipse-mat/''${version}/configuration"
86
87 # Create desktop item.
88 mkdir -p $out/share/applications
89 cp ${desktopItem}/share/applications/* $out/share/applications
90 mkdir -p $out/share/pixmaps
91 find $out/mat/plugins -name 'eclipse*.png' -type f -exec cp {} $out/share/pixmaps \;
92 mv $out/share/pixmaps/eclipse64.png $out/share/pixmaps/eclipse.png
93 '';
94
95 nativeBuildInputs = [
96 unzip
97 makeWrapper
98 ];
99 buildInputs = [
100 fontconfig
101 freetype
102 glib
103 gsettings-desktop-schemas
104 gtk3
105 jdk
106 libX11
107 libXrender
108 libXtst
109 zlib
110 shared-mime-info
111 webkitgtk_4_1
112 ];
113
114 dontBuild = true;
115 dontConfigure = true;
116
117 meta = with lib; {
118 description = "Fast and feature-rich Java heap analyzer";
119 mainProgram = "eclipse-mat";
120 longDescription = ''
121 The Eclipse Memory Analyzer is a tool that helps you find memory
122 leaks and reduce memory consumption. Use the Memory Analyzer to
123 analyze productive heap dumps with hundreds of millions of
124 objects, quickly calculate the retained sizes of objects, see
125 who is preventing the Garbage Collector from collecting objects,
126 run a report to automatically extract leak suspects.
127 '';
128 homepage = "https://www.eclipse.org/mat";
129 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
130 license = licenses.epl20;
131 maintainers = [ maintainers.ktor ];
132 platforms = [ "x86_64-linux" ];
133 };
134
135}