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
21with lib;
22let
23 pVersion = "1.13.0.20220615";
24 pVersionTriple = splitVersion pVersion;
25 majorVersion = elemAt pVersionTriple 0;
26 minorVersion = elemAt pVersionTriple 1;
27 patchVersion = elemAt pVersionTriple 2;
28 baseVersion = "${majorVersion}.${minorVersion}.${patchVersion}";
29 jdk = jdk11;
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-LwtP76kb9xgdcsWCSCXeRbhFVyFS3xkl15F075Cq4Os=";
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 [ freetype fontconfig libX11 libXrender zlib ]
65 } $libCairo
66
67 # Create wrapper script. Pass -configuration to store settings in ~/.eclipse-mat/<version>
68 makeWrapper $out/mat/MemoryAnalyzer $out/bin/eclipse-mat \
69 --prefix PATH : ${jdk}/bin \
70 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath ([ glib gtk3 libXtst webkitgtk ])} \
71 --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
72 --add-flags "-configuration \$HOME/.eclipse-mat/''${version}/configuration"
73
74 # Create desktop item.
75 mkdir -p $out/share/applications
76 cp ${desktopItem}/share/applications/* $out/share/applications
77 mkdir -p $out/share/pixmaps
78 find $out/mat/plugins -name 'eclipse*.png' -type f -exec cp {} $out/share/pixmaps \;
79 mv $out/share/pixmaps/eclipse64.png $out/share/pixmaps/eclipse.png
80 '';
81
82 nativeBuildInputs = [ unzip makeWrapper ];
83 buildInputs = [
84 fontconfig
85 freetype
86 glib
87 gsettings-desktop-schemas
88 gtk3
89 jdk
90 libX11
91 libXrender
92 libXtst
93 zlib
94 shared-mime-info
95 webkitgtk
96 ];
97
98 dontBuild = true;
99 dontConfigure = true;
100
101 meta = with lib; {
102 description = "Fast and feature-rich Java heap analyzer";
103 longDescription = ''
104 The Eclipse Memory Analyzer is a tool that helps you find memory
105 leaks and reduce memory consumption. Use the Memory Analyzer to
106 analyze productive heap dumps with hundreds of millions of
107 objects, quickly calculate the retained sizes of objects, see
108 who is preventing the Garbage Collector from collecting objects,
109 run a report to automatically extract leak suspects.
110 '';
111 homepage = "https://www.eclipse.org/mat";
112 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
113 license = licenses.epl20;
114 maintainers = [ maintainers.ktor ];
115 platforms = [ "x86_64-linux" ];
116 };
117
118}