nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildNpmPackage,
5 fetchFromGitHub,
6 makeWrapper,
7 makeDesktopItem,
8 copyDesktopItems,
9 electron_39,
10 httptoolkit-server,
11}:
12
13let
14 electron = electron_39;
15in
16buildNpmPackage rec {
17 pname = "httptoolkit";
18
19 # update together with httptoolkit-server
20 # nixpkgs-update: no auto update
21 version = "1.24.4";
22
23 src = fetchFromGitHub {
24 owner = "httptoolkit";
25 repo = "httptoolkit-desktop";
26 tag = "v${version}";
27 hash = "sha256-b1u+DFhxU/ED4GgMHFaF51zNfC+0vIg6ujyA8jIy8AQ=";
28 };
29
30 npmDepsHash = "sha256-FX8sClJL66zvWEaaw0lmoat7cM396RA8Rq9NgRVh0Vw=";
31
32 makeCacheWritable = true;
33
34 env = {
35 ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
36 # disable code signing on Darwin
37 CSC_IDENTITY_AUTO_DISCOVERY = "false";
38 };
39
40 nativeBuildInputs = [
41 makeWrapper
42 ]
43 ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ];
44
45 npmBuildScript = "build:src";
46
47 postBuild = ''
48 substituteInPlace package.json --replace-fail \
49 '"forceCodeSigning": true' \
50 '"forceCodeSigning": false'
51
52 cp -rL ${electron.dist} electron-dist
53 chmod -R u+w electron-dist
54
55 npm exec electron-builder -- \
56 --dir \
57 -c.electronDist=electron-dist \
58 -c.electronVersion=${electron.version}
59 '';
60
61 installPhase = ''
62 runHook preInstall
63
64 ${lib.optionalString stdenv.hostPlatform.isLinux ''
65 mkdir -p $out/share/httptoolkit
66 cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/httptoolkit
67
68 ln -s ${httptoolkit-server} $out/share/httptoolkit/resources/httptoolkit-server
69
70 install -Dm644 src/icons/icon.svg $out/share/icons/hicolor/scalable/apps/httptoolkit.svg
71
72 makeWrapper ${lib.getExe electron} $out/bin/httptoolkit \
73 --add-flags $out/share/httptoolkit/resources/app.asar \
74 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
75 --inherit-argv0
76 ''}
77
78 ${lib.optionalString stdenv.hostPlatform.isDarwin ''
79 mkdir -p $out/Applications
80 cp -r dist/mac*/"HTTP Toolkit.app" $out/Applications
81
82 ln -s ${httptoolkit-server} "$out/Applications/HTTP Toolkit.app/Contents/Resources/httptoolkit-server"
83
84 makeWrapper "$out/Applications/HTTP Toolkit.app/Contents/MacOS/HTTP Toolkit" $out/bin/httptoolkit
85 ''}
86
87 runHook postInstall
88 '';
89
90 desktopItems = [
91 (makeDesktopItem {
92 name = "httptoolkit";
93 desktopName = "HTTP Toolkit";
94 exec = "httptoolkit %U";
95 terminal = false;
96 icon = "httptoolkit";
97 startupWMClass = "HTTP Toolkit";
98 comment = meta.description;
99 categories = [ "Development" ];
100 startupNotify = true;
101 })
102 ];
103
104 meta = {
105 description = "HTTP(S) debugging, development & testing tool";
106 homepage = "https://httptoolkit.com/";
107 license = lib.licenses.agpl3Plus;
108 mainProgram = "httptoolkit";
109 maintainers = with lib.maintainers; [ tomasajt ];
110 platforms = electron.meta.platforms;
111 };
112}