From e9e34062c26d74c513dcddd85d23a91aefb2ae7d Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:01:20 -0600 Subject: [PATCH] fix(browsers): forward package.override through the Firefox/Zen BiDi wrappers (code#6156) PR #6146 handed home-manager a bare symlinkJoin as programs.firefox.package. mkFirefoxModule treats a wrapped package as reconfigurable only through its override: it probes lib.functionArgs package.override for cfg/appDataDir and calls it with an override function merging cfg, extraPolicies and pkcs11Modules. A symlinkJoin has no override, so evaluating the HM generation on main failed with "attribute override missing" and blocked every HM activation / NixOS switch for the host. Wrap the join in a passthrough: joined // { override = lib.setFunctionArgs (args: wrap (pkg.override args)) (lib.functionArgs pkg.override); } -- the module now behaves exactly as it does for pkgs.firefox (its policies/configPath merges land in the wrapped package it installs), and the BiDi wrap is re-applied to whatever the override returns. Same forwarding added to wrapFirefoxBidi in nixos/environment (guarded by pkg ? override) so both definitions of the wrapper carry the same contract. Verified: the failing eval now returns a drvPath; toplevel drvPaths evaluate for amd, nixos, vm_amd, vm_nixos and user; the module-composed HM firefox package builds with --remote-debugging-port=19225 and its inner policies.json carries the module policy (BlockAboutConfig); zen wrapper builds with port 19226; the environment firefox/zen wrapper outPaths are byte-identical to pre-fix main (passthrough attrs do not change the builds); both files are nixfmt-clean. --- home/common/default.nix | 58 ++++++++++++++++++++++++----------- nixos/environment/default.nix | 48 +++++++++++++++++++---------- 2 files changed, 71 insertions(+), 35 deletions(-) diff --git a/home/common/default.nix b/home/common/default.nix index 94a77a7077..007e0f7097 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -199,24 +199,46 @@ let # 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; - }; - }; + firefoxBidi = + let + wrapBidi = + pkg: + let + joined = 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=19225" + done + ''; + meta = (pkg.meta or { }) // { + mainProgram = pkg.meta.mainProgram or null; + }; + }; + in + joined + // { + # home-manager's firefox module (mkFirefoxModule) treats a + # wrapped package as reconfigurable only through its + # `override`: it probes `lib.functionArgs package.override` + # for `cfg` / `appDataDir` and calls it with an override + # function merging cfg, extraPolicies and pkcs11Modules. + # A bare symlinkJoin has no `override`, which broke the HM + # evaluation of main in code#6156. Forward the underlying + # package's override -- re-applying the BiDi wrap to its + # result, with the override's exact function-args shape -- + # so the module behaves exactly as it does for pkgs.firefox. + override = lib.setFunctionArgs (args: wrapBidi (pkg.override args)) (lib.functionArgs pkg.override); + }; + in + wrapBidi pkgs.firefox; # The environment the mcpx daemon runs with (services.mcpx.environment # below; the module renders it into the unit). mcpxEnvironment = { diff --git a/nixos/environment/default.nix b/nixos/environment/default.nix index 7d43da31ed..7292410a49 100644 --- a/nixos/environment/default.nix +++ b/nixos/environment/default.nix @@ -315,24 +315,38 @@ let # `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; + wrapFirefoxBidi = + name: pkg: port: + let + joined = 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; + }; }; + in + joined + // lib.optionalAttrs (pkg ? override) { + # Keep the wrapped package override-compatible (code#6156): + # consumers such as home-manager's firefox module probe and + # call `package.override`; a bare symlinkJoin has none. + # Forward the underlying package's override, re-applying this + # wrap to its result and preserving its function-args shape. + override = lib.setFunctionArgs (args: wrapFirefoxBidi name (pkg.override args) port) ( + lib.functionArgs pkg.override + ); }; zenBidi = wrapFirefoxBidi "zen" inputs.zen-browser.packages.${system}.default 19226;