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