summary refs log tree commit diff
path: root/pkgs/applications/networking/charles/default.nix
blob: 064213b01ae33ddd0b727eb64ea8e61f5e2ec41b (plain) (blame)
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
{ lib
, stdenv
, makeWrapper
, makeDesktopItem
, fetchurl
, jdk11
, jdk8
}:

let
  generic = { version, sha256, platform ? "", jdk, ... }@attrs:
  let
    desktopItem = makeDesktopItem {
      categories = [ "Network" "Development" "WebDevelopment" "Java" ];
      desktopName = "Charles";
      exec = "charles %F";
      genericName  = "Web Debugging Proxy";
      icon = "charles-proxy";
      mimeTypes = [
        "application/x-charles-savedsession"
        "application/x-charles-savedsession+xml"
        "application/x-charles-savedsession+json"
        "application/har+json"
        "application/vnd.tcpdump.pcap"
        "application/x-charles-trace"
      ];
      name = "Charles";
      startupNotify = true;
    };

  in stdenv.mkDerivation {
      pname = "charles";
      inherit version;

      src = fetchurl {
        url = "https://www.charlesproxy.com/assets/release/${version}/charles-proxy-${version}${platform}.tar.gz";
        inherit sha256;
      };
      nativeBuildInputs = [ makeWrapper ];

      installPhase = ''
        makeWrapper ${jdk}/bin/java $out/bin/charles \
          --add-flags "-Xmx1024M -Dcharles.config='~/.charles.config' -jar $out/share/java/charles.jar"

        for fn in lib/*.jar; do
          install -D -m644 $fn $out/share/java/$(basename $fn)
        done

        mkdir -p $out/share/applications
        ln -s ${desktopItem}/share/applications/* $out/share/applications/

        mkdir -p $out/share/icons
        cp -r icon $out/share/icons/hicolor
      '';

      meta = with lib; {
        description = "Web Debugging Proxy";
        homepage = "https://www.charlesproxy.com/";
        maintainers = with maintainers; [ kalbasit ];
        license = licenses.unfree;
        platforms = platforms.unix;
      };
    };

in {
  charles4 = (generic {
    version = "4.6.2";
    sha256 = "0r5rann7cq665ih0pa66k52081gylk85ashrwq1khbv2jf80yy52";
    platform = "_amd64";
    jdk = jdk11;
  });
  charles3 = (generic {
    version = "3.12.3";
    sha256 = "13zk82ny1w5zd9qcs9qkq0kdb22ni5byzajyshpxdfm4zv6p32ss";
    jdk = jdk8.jre;
  });
}