From 083d96b112b2ec21ebcbc9def9eabaf3db697398 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Sun, 17 May 2026 20:22:16 +0200 Subject: [PATCH] httptoolkit: 1.24.4 -> 1.26.0 --- pkgs/by-name/ht/httptoolkit/fix-paths.patch | 60 +++++++++++++++ pkgs/by-name/ht/httptoolkit/package.nix | 84 +++++++++++---------- 2 files changed, 106 insertions(+), 38 deletions(-) create mode 100644 pkgs/by-name/ht/httptoolkit/fix-paths.patch diff --git a/pkgs/by-name/ht/httptoolkit/fix-paths.patch b/pkgs/by-name/ht/httptoolkit/fix-paths.patch new file mode 100644 index 000000000000..7daa244be10e --- /dev/null +++ b/pkgs/by-name/ht/httptoolkit/fix-paths.patch @@ -0,0 +1,60 @@ +diff --git a/httptoolkit-ctl b/httptoolkit-ctl +index 0878247..d299b71 100644 +--- a/httptoolkit-ctl ++++ b/httptoolkit-ctl +@@ -1,10 +1,5 @@ + #!/bin/sh + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +-APP_DIR="$(dirname "$SCRIPT_DIR")" + export HTK_DESKTOP_RESOURCES="$SCRIPT_DIR" +-if [ "$(uname)" = "Darwin" ]; then +- export HTK_DESKTOP_EXE="$APP_DIR/MacOS/HTTP Toolkit" +-else +- export HTK_DESKTOP_EXE="$APP_DIR/httptoolkit" +-fi ++export HTK_DESKTOP_EXE="@out@/bin/httptoolkit" + exec "$SCRIPT_DIR/httptoolkit-server/bin/httptoolkit-server" ctl "$@" +diff --git a/httptoolkit-mcp b/httptoolkit-mcp +index c27b25a..c7b3f07 100644 +--- a/httptoolkit-mcp ++++ b/httptoolkit-mcp +@@ -1,10 +1,5 @@ + #!/bin/sh + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +-APP_DIR="$(dirname "$SCRIPT_DIR")" + export HTK_DESKTOP_RESOURCES="$SCRIPT_DIR" +-if [ "$(uname)" = "Darwin" ]; then +- export HTK_DESKTOP_EXE="$APP_DIR/MacOS/HTTP Toolkit" +-else +- export HTK_DESKTOP_EXE="$APP_DIR/httptoolkit" +-fi ++export HTK_DESKTOP_EXE="@out@/bin/httptoolkit" + exec "$SCRIPT_DIR/httptoolkit-server/bin/httptoolkit-server" mcp "$@" +diff --git a/package.json b/package.json +index e6a9ef4..f8d7ec1 100644 +--- a/package.json ++++ b/package.json +@@ -58,8 +58,8 @@ + ], + "extraResources": [ + "httptoolkit-server/**/*", +- "httptoolkit-ctl{,.*}", +- "httptoolkit-mcp{,.*}" ++ "httptoolkit-ctl", ++ "httptoolkit-mcp" + ], + "artifactName": "HttpToolkit-${version}-${arch}.${ext}", + "mac": { +diff --git a/src/index.ts b/src/index.ts +index 8a63c58..0511575 100644 +--- a/src/index.ts ++++ b/src/index.ts +@@ -392,7 +392,7 @@ if (!amMainInstance) { + ...process.env, + + HTK_SERVER_TOKEN: AUTH_TOKEN, +- HTK_DESKTOP_EXE: app.getPath('exe'), ++ HTK_DESKTOP_EXE: '@out@/bin/httptoolkit', + HTK_DESKTOP_RESOURCES: RESOURCES_PATH, + NODE_SKIP_PLATFORM_CHECK: '1', + OPENSSL_CONF: undefined, // Not relevant to us, and if set this can crash Node.js diff --git a/pkgs/by-name/ht/httptoolkit/package.nix b/pkgs/by-name/ht/httptoolkit/package.nix index 0c759847c9cb..8194b6a66a7d 100644 --- a/pkgs/by-name/ht/httptoolkit/package.nix +++ b/pkgs/by-name/ht/httptoolkit/package.nix @@ -1,89 +1,97 @@ { lib, stdenv, + buildNpmPackage, fetchFromGitHub, - makeWrapper, makeDesktopItem, + copyDesktopItems, - electron_39, + makeWrapper, + xcbuild, + + electron_41, httptoolkit-server, }: let - electron = electron_39; + electron = electron_41; in buildNpmPackage rec { pname = "httptoolkit"; # update together with httptoolkit-server # nixpkgs-update: no auto update - version = "1.24.4"; + version = "1.26.0"; src = fetchFromGitHub { owner = "httptoolkit"; repo = "httptoolkit-desktop"; tag = "v${version}"; - hash = "sha256-b1u+DFhxU/ED4GgMHFaF51zNfC+0vIg6ujyA8jIy8AQ="; + hash = "sha256-WEl0DGYdq1qa5zNEVO6L8TW6lgNTI0NdL0YXeR3Z0BI="; }; - npmDepsHash = "sha256-FX8sClJL66zvWEaaw0lmoat7cM396RA8Rq9NgRVh0Vw="; + patches = [ + ./fix-paths.patch + ]; + + postPatch = '' + substituteInPlace httptoolkit-{mcp,ctl} src/index.ts \ + --replace-fail "@out@" "$out" + ''; + + npmDepsHash = "sha256-fGVxHhJU/1ZsRyX3AnP6jM/jkY0PZHKDA1tb2z06lLs="; makeCacheWritable = true; - env = { - ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; - # disable code signing on Darwin - CSC_IDENTITY_AUTO_DISCOVERY = "false"; - }; + env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; nativeBuildInputs = [ makeWrapper ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ]; + ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ]; npmBuildScript = "build:src"; postBuild = '' - substituteInPlace package.json --replace-fail \ - '"forceCodeSigning": true' \ - '"forceCodeSigning": false' - cp -rL ${electron.dist} electron-dist chmod -R u+w electron-dist npm exec electron-builder -- \ - --dir \ - -c.electronDist=electron-dist \ - -c.electronVersion=${electron.version} + --dir \ + -c.electronDist=electron-dist \ + -c.electronVersion=${electron.version} \ + -c.mac.forceCodeSigning=false \ + -c.mac.identity=null + # ^ this disables codesigning on Darwin ''; installPhase = '' runHook preInstall + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + mkdir -p $out/share/httptoolkit + cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/httptoolkit - ${lib.optionalString stdenv.hostPlatform.isLinux '' - mkdir -p $out/share/httptoolkit - cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/httptoolkit + ln -s ${httptoolkit-server} $out/share/httptoolkit/resources/httptoolkit-server - ln -s ${httptoolkit-server} $out/share/httptoolkit/resources/httptoolkit-server + install -Dm644 src/icons/icon.svg $out/share/icons/hicolor/scalable/apps/httptoolkit.svg - install -Dm644 src/icons/icon.svg $out/share/icons/hicolor/scalable/apps/httptoolkit.svg + makeWrapper ${lib.getExe electron} $out/bin/httptoolkit \ + --add-flags $out/share/httptoolkit/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ + --inherit-argv0 + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Applications + cp -r dist/mac*/"HTTP Toolkit.app" $out/Applications - makeWrapper ${lib.getExe electron} $out/bin/httptoolkit \ - --add-flags $out/share/httptoolkit/resources/app.asar \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ - --inherit-argv0 - ''} - - ${lib.optionalString stdenv.hostPlatform.isDarwin '' - mkdir -p $out/Applications - cp -r dist/mac*/"HTTP Toolkit.app" $out/Applications - - ln -s ${httptoolkit-server} "$out/Applications/HTTP Toolkit.app/Contents/Resources/httptoolkit-server" - - makeWrapper "$out/Applications/HTTP Toolkit.app/Contents/MacOS/HTTP Toolkit" $out/bin/httptoolkit - ''} + ln -s ${httptoolkit-server} "$out/Applications/HTTP Toolkit.app/Contents/Resources/httptoolkit-server" + makeWrapper "$out/Applications/HTTP Toolkit.app/Contents/MacOS/HTTP Toolkit" $out/bin/httptoolkit + '' + + '' runHook postInstall '';