diff --git a/home/common/default.nix b/home/common/default.nix index 7668012477..575dfe873f 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -153,6 +153,44 @@ let install -Dm755 ${opencodeWrapper} $out/bin/opencode ''; }; + + # Brave with structural CDP (code#5924 follow-up): Brave is + # Chromium-family, so it takes the same --remote-debugging flags + # as Helium (19222) and system Chromium (19224); Brave gets + # 19223, loopback-only. Same wrapper shape as + # wrapElectronWithFlags in nixos/environment (binaries wrapped, + # desktop entries repointed at the wrappers) so every launch + # path -- shell or launcher -- carries the flags. Caller-passed + # flags come after wrapper flags and win. + braveCdp = pkgs.symlinkJoin { + name = "${pkgs.brave.name}-cdp"; + paths = [ pkgs.brave ]; + 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-address=127.0.0.1" \ + --add-flags "--remote-debugging-port=19223" + done + + if [ -d "$out/share/applications" ]; then + for f in "$out"/share/applications/*.desktop; do + [ -e "$f" ] || continue + src=$(readlink -f "$f") + base=$(basename "$f") + rm "$f" + sed "s|${pkgs.brave}/bin/|$out/bin/|g" "$src" > "$out/share/applications/$base" + done + fi + ''; + meta = (pkgs.brave.meta or { }) // { + mainProgram = pkgs.brave.meta.mainProgram or null; + }; + }; # The environment the mcpx daemon runs with (services.mcpx.environment # below; the module renders it into the unit). mcpxEnvironment = { @@ -1892,7 +1930,7 @@ in bluez bluez-tools bottom - brave + braveCdp # brave + structural CDP on 127.0.0.1:19223 (code#5924) brig brightnessctl brillo diff --git a/nixos/environment/default.nix b/nixos/environment/default.nix index 869f072dde..07b8334a82 100644 --- a/nixos/environment/default.nix +++ b/nixos/environment/default.nix @@ -261,7 +261,40 @@ let scaleElectron2x = wrapElectronWithFlags "scaled2x" [ "--force-device-scale-factor=2" ]; - # OpenChamber's Electron GUI, built from the developing-today-forks/openchamber fork. + # Chromium with structural CDP (code#5924 follow-up): the fleet + # Chromium entries must always expose the DevTools endpoint on + # loopback -- 19224 (convention: 19222 Helium, 19223 Brave, + # 19224 Chromium). wrapElectronWithFlags cannot be reused here: + # the wrapped chromium package symlinks share/applications into + # chromium-unwrapped's tree, and the helper's in-place desktop + # rewrite fails on the read-only target. No rewrite is needed: + # chromium's desktop file uses a bare `Exec=chromium`, resolved + # through PATH, so wrapping bin/ covers shell and launcher + # launches alike. Wrapper flags precede caller args, so + # automation passing its own --remote-debugging-port + # (playwright/puppeteer via mcpx) still wins. + chromiumPkg = inputs.nixpkgs-unstable.legacyPackages.${system}.chromium; + chromiumCdp = pkgs.symlinkJoin { + name = "${chromiumPkg.name}-cdp"; + paths = [ chromiumPkg ]; + 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-address=127.0.0.1" \ + --add-flags "--remote-debugging-port=19224" + done + ''; + meta = (chromiumPkg.meta or { }) // { + mainProgram = chromiumPkg.meta.mainProgram or null; + }; + }; + + # OpenChamber's Electron GUI, built from the developing-today/openchamber fork. openchamber-desktop = inputs.openchamber.packages.${system}.openchamber-desktop; # OpenChamber CLI/server built from the developing-today-forks/openchamber fork. @@ -1249,7 +1282,7 @@ in # Testing and development tools #beekeeper-studio # electron 31 eol #cypress # electron 37 eol: insecure in this nixpkgs - inputs.nixpkgs-unstable.legacyPackages.${system}.chromium # nixos-unstable channel: cached (master chromium is not) + chromiumCdp # chromium + structural CDP on 127.0.0.1:19224 (code#5924); nixos-unstable channel: cached (master chromium is not) inputs.nixpkgs-unstable.legacyPackages.${system}.chromedriver playwright-driver direnv