diff --git a/home/common/default.nix b/home/common/default.nix index 575dfe873f..94a77a7077 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -191,6 +191,32 @@ let mainProgram = pkgs.brave.meta.mainProgram or null; }; }; + # Firefox with structural WebDriver BiDi (code#5924 follow-up): + # Firefox has no CDP; --remote-debugging-port starts its + # WebDriver BiDi remote agent (binds 127.0.0.1 itself; default + # Host/Origin policy kept -- see nixos/environment for the full + # port table: 19225 Firefox BiDi, 19226 Zen BiDi). Home-manager + # installs this as the programs.firefox package below; the + # NixOS side installs the same wrapper via + # environment.systemPackages (nixos/environment firefoxBidi). + firefoxBidi = pkgs.symlinkJoin { + name = "${pkgs.firefox.name}-bidi"; + paths = [ pkgs.firefox ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + for bin in "$out"/bin/*; do + [ -L "$bin" ] || continue + target=$(readlink -f "$bin") + [ -x "$target" ] || continue + rm "$bin" + makeWrapper "$target" "$bin" \ + --add-flags "--remote-debugging-port=19225" + done + ''; + meta = (pkgs.firefox.meta or { }) // { + mainProgram = pkgs.firefox.meta.mainProgram or null; + }; + }; # The environment the mcpx daemon runs with (services.mcpx.environment # below; the module renders it into the unit). mcpxEnvironment = { @@ -1378,6 +1404,7 @@ in #eza.enable = true; firefox = { enable = true; + package = firefoxBidi; # structural WebDriver BiDi on 127.0.0.1:19225 (code#5924) # pin legacy path explicitly; default changed to xdg.configHome in 26.05 configPath = ".mozilla/firefox"; policies = { diff --git a/nixos/environment/default.nix b/nixos/environment/default.nix index 07b8334a82..7d43da31ed 100644 --- a/nixos/environment/default.nix +++ b/nixos/environment/default.nix @@ -294,6 +294,49 @@ let }; }; + # Firefox-family with structural WebDriver BiDi (code#5924 + # follow-up): Firefox and Zen have no CDP -- their remote + # protocol is WebDriver BiDi, started by --remote-debugging-port + # in current Firefox (verified against the installed + # Firefox 159.0: "WebDriver BiDi listening on ws://127.0.0.1" + # + a session.status round trip). Fleet port convention, one + # table for every browser remote endpoint, loopback-only: + # 19222 Helium CDP 19225 Firefox BiDi + # 19223 Brave/Chrome CDP 19226 Zen BiDi + # 19224 Chromium CDP 19227 Zen Twilight BiDi (darwin only) + # The remote agent binds 127.0.0.1 by itself, and its default + # policy is kept deliberately: foreign Host headers get 400 + # and Origin-bearing upgrade requests get no WebSocket, so + # web content on this machine cannot hijack the socket. Local + # agent tooling (no Origin) works as-is; a caller that needs + # an Origin passes --remote-allow-origins itself -- caller + # args follow wrapper flags. Same bin-only wrapper shape as + # chromiumCdp: both packages' desktop files use bare + # `Exec=firefox` / `Exec=zen-beta`, resolved through PATH, so + # wrapping bin/ covers shell and launcher launches alike. + firefoxBidi = wrapFirefoxBidi "firefox" pkgs.firefox 19225; + wrapFirefoxBidi = name: pkg: port: + pkgs.symlinkJoin { + name = "${pkg.name}-bidi"; + paths = [ pkg ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + for bin in "$out"/bin/*; do + [ -L "$bin" ] || continue + target=$(readlink -f "$bin") + [ -x "$target" ] || continue + rm "$bin" + makeWrapper "$target" "$bin" \ + --add-flags "--remote-debugging-port=${toString port}" + done + ''; + meta = (pkg.meta or { }) // { + mainProgram = pkg.meta.mainProgram or null; + }; + }; + + zenBidi = wrapFirefoxBidi "zen" inputs.zen-browser.packages.${system}.default 19226; + # OpenChamber's Electron GUI, built from the developing-today/openchamber fork. openchamber-desktop = inputs.openchamber.packages.${system}.openchamber-desktop; @@ -506,7 +549,7 @@ in nix-output-monitor.packages.${system}.default ssh-to-age.packages.${system}.default nix-search.packages.${system}.default - zen-browser.packages.${system}.default + zenBidi # zen + structural WebDriver BiDi on 127.0.0.1:19226 (code#5924) #hyprland-qtutils.packages.${system}.hyprland-qtutils clan-core.packages.${system}.clan-cli opencode.packages.${system}.opencode @@ -1283,6 +1326,7 @@ in #beekeeper-studio # electron 31 eol #cypress # electron 37 eol: insecure in this nixpkgs chromiumCdp # chromium + structural CDP on 127.0.0.1:19224 (code#5924); nixos-unstable channel: cached (master chromium is not) + firefoxBidi # firefox + structural WebDriver BiDi on 127.0.0.1:19225 (code#5924); also the HM programs.firefox package (home/common) inputs.nixpkgs-unstable.legacyPackages.${system}.chromedriver playwright-driver direnv diff --git a/nixos/users/backup/default.nix b/nixos/users/backup/default.nix index bb4f07e3e4..179895a4ee 100644 --- a/nixos/users/backup/default.nix +++ b/nixos/users/backup/default.nix @@ -33,7 +33,7 @@ "beep" ]; packages = with pkgs; [ - firefox + # firefox comes from environment.systemPackages as firefoxBidi (structural BiDi, code#5924) kdePackages.kate ]; }; diff --git a/nixos/users/user-for-vm/default.nix b/nixos/users/user-for-vm/default.nix index 92abcc6411..12628515c3 100644 --- a/nixos/users/user-for-vm/default.nix +++ b/nixos/users/user-for-vm/default.nix @@ -24,7 +24,7 @@ "beep" ]; packages = with pkgs; [ - firefox + # firefox comes from environment.systemPackages as firefoxBidi (structural BiDi, code#5924) kdePackages.kate ]; }; diff --git a/nixos/users/user/default.nix b/nixos/users/user/default.nix index dfcbed3e05..19c9f276e0 100644 --- a/nixos/users/user/default.nix +++ b/nixos/users/user/default.nix @@ -58,7 +58,7 @@ "wireshark" # USB and network protocol capture ]; packages = with pkgs; [ - firefox + # firefox comes from environment.systemPackages as firefoxBidi (structural BiDi, code#5924) kdePackages.kate ]; };