hanko: add updateScript (#372233)
[NixPkgs.git] / pkgs / applications / networking / charles / default.nix
bloba76be42cf11216ec0335fd8b534c163e3358ec01
2   lib,
3   stdenv,
4   makeWrapper,
5   makeDesktopItem,
6   fetchurl,
7   jdk11,
8   jdk8,
9 }:
11 let
12   generic =
13     {
14       version,
15       sha256,
16       platform ? "",
17       jdk,
18       ...
19     }@attrs:
20     let
21       desktopItem = makeDesktopItem {
22         categories = [
23           "Network"
24           "Development"
25           "WebDevelopment"
26           "Java"
27         ];
28         desktopName = "Charles";
29         exec = "charles %F";
30         genericName = "Web Debugging Proxy";
31         icon = "charles-proxy";
32         mimeTypes = [
33           "application/x-charles-savedsession"
34           "application/x-charles-savedsession+xml"
35           "application/x-charles-savedsession+json"
36           "application/har+json"
37           "application/vnd.tcpdump.pcap"
38           "application/x-charles-trace"
39         ];
40         name = "Charles";
41         startupNotify = true;
42       };
44     in
45     stdenv.mkDerivation {
46       pname = "charles";
47       inherit version;
49       src = fetchurl {
50         url = "https://www.charlesproxy.com/assets/release/${version}/charles-proxy-${version}${platform}.tar.gz";
51         curlOptsList = [
52           "--user-agent"
53           "Mozilla/5.0"
54         ]; # HTTP 104 otherwise
55         inherit sha256;
56       };
57       nativeBuildInputs = [ makeWrapper ];
59       installPhase = ''
60         makeWrapper ${jdk}/bin/java $out/bin/charles \
61           --add-flags "-Xmx1024M -Dcharles.config='~/.charles.config' -jar $out/share/java/charles.jar"
63         for fn in lib/*.jar; do
64           install -D -m644 $fn $out/share/java/$(basename $fn)
65         done
67         mkdir -p $out/share/applications
68         ln -s ${desktopItem}/share/applications/* $out/share/applications/
70         mkdir -p $out/share/icons
71         cp -r icon $out/share/icons/hicolor
72       '';
74       meta = with lib; {
75         description = "Web Debugging Proxy";
76         homepage = "https://www.charlesproxy.com/";
77         maintainers = with maintainers; [
78           kalbasit
79           kashw2
80         ];
81         sourceProvenance = with sourceTypes; [ binaryBytecode ];
82         license = licenses.unfree;
83         platforms = platforms.unix;
84       };
85     };
89   charles4 = (
90     generic {
91       version = "4.6.4";
92       sha256 = "KEQYb90kt41dS3TJLZqdaV9P3mQA9UPsEyiFb/knm3w=";
93       platform = "_amd64";
94       jdk = jdk11;
95     }
96   );
97   charles3 = (
98     generic {
99       version = "3.12.3";
100       sha256 = "13zk82ny1w5zd9qcs9qkq0kdb22ni5byzajyshpxdfm4zv6p32ss";
101       jdk = jdk8.jre;
102       mainProgram = "charles";
103     }
104   );