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