summaryrefslogtreecommitdiff
path: root/pkgs/development/tools/java/jprofiler/default.nix
blob: 753dfddeb2b081637e1aa3cd21e05a372e397c34 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{
  stdenv,
  lib,
  fetchurl,
  makeWrapper,
  makeDesktopItem,
  copyDesktopItems,
  _7zz,
  jdk,
}:

let
  pname = "jprofiler";
  version = "14.0.5";
  nameApp = "JProfiler";

  meta = {
    description = "Java profiler for deep JVM analysis";
    longDescription = ''
      JProfiler bridges high-level analytics and low-level JVM data,
      delivering unmatched insights to solve your toughest performance
      problems, memory leaks, threading issues, and higher-level problems in
      technologies like JDBC, JPA, and more.
    '';
    homepage = "https://www.ej-technologies.com/products/jprofiler/overview.html";
    license = lib.licenses.unfree;
    maintainers = [ ];
  };

  src =
    if stdenv.hostPlatform.isLinux then
      fetchurl {
        url = "https://download.ej-technologies.com/jprofiler/jprofiler_linux_${
          lib.replaceStrings [ "." ] [ "_" ] version
        }.tar.gz";
        hash = "sha256-S7e2WurDJ0ePzpMg0YK94Mn0eHfb8/jNmf0kYts2Y0M=";
      }
    else
      fetchurl {
        url = "https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_macos_${
          lib.replaceStrings [ "." ] [ "_" ] version
        }.dmg";
        hash = "sha256-HPGh+dRfLuQprpgnu8oFboHUB1xvFqPblJcowqgZ5KA=";
      };

  desktopItems = [
    (makeDesktopItem {
      name = pname;
      exec = pname;
      icon = pname;
      comment = meta.description;
      desktopName = nameApp;
      genericName = "Java Profiler Tool";
      categories = [ "Development" ];
    })
  ];

  linux = stdenv.mkDerivation {
    inherit
      pname
      version
      src
      desktopItems
      ;

    nativeBuildInputs = [
      makeWrapper
      copyDesktopItems
    ];

    installPhase = ''
      runHook preInstall

      cp -r . $out

      rm -f $out/bin/updater
      rm -rf $out/bin/linux-ppc*
      rm -rf $out/bin/linux-armhf
      rm -rf $out/bin/linux-musl*

      for f in $(find $out/bin -type f -executable); do
        wrapProgram $f --set JAVA_HOME "${jdk.home}"
      done

      install -Dm644 "./.install4j/i4j_extf_7_1u09tly_16qtnph.png" \
        "$out/share/icons/hicolor/scalable/apps/jprofiler.png"

      runHook postInstall
    '';

    meta = meta // {
      platforms = lib.platforms.linux;
    };
  };

  darwin = stdenv.mkDerivation {
    inherit pname version src;

    nativeBuildInputs = [
      makeWrapper
      _7zz
    ];

    unpackPhase = ''
      runHook preUnpack

      7zz x $src -x!JProfiler/\[\]

      runHook postUnpack
    '';

    sourceRoot = nameApp;

    installPhase = ''
      runHook preInstall

      mkdir -p $out/{Applications,bin}
      cp -R ${nameApp}.app $out/Applications/
      makeWrapper $out/Applications/${nameApp}.app/Contents/MacOS/JavaApplicationStub $out/bin/${pname}

      runHook postInstall
    '';

    meta = meta // {
      platforms = lib.platforms.darwin;
    };
  };
in
if stdenv.hostPlatform.isDarwin then darwin else linux