Patch Zen window sync blank tabs
This commit is contained in:
parent
8793ecea4d
commit
81a5fef0b3
3 changed files with 278 additions and 33 deletions
96
apps/zen.nix
96
apps/zen.nix
|
|
@ -1,6 +1,19 @@
|
|||
#./apps/zen.nix
|
||||
{ inputs, pkgs, lib, config, ... }:
|
||||
let
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
# Zen keeps one live docshell for each logical tab and mirrors about:blank
|
||||
# placeholders into the other synced windows. Upstream 1.23b changes the
|
||||
# placeholder's ownership flags before confirming that the docshell swap
|
||||
# succeeded (zen-browser/desktop#15702), so one failed swap can promote the
|
||||
# blank placeholder and make later selections show "New Tab". Patch the
|
||||
# shipped browser module until Zen includes an upstream fix.
|
||||
windowSyncPatch = ../patches/zen-browser/window-sync-commit-ownership-after-swap.patch;
|
||||
|
||||
# Autoconfig (mozilla.cfg) runs privileged JS in the parent process at
|
||||
# startup — the only scriptable way into chrome, since Gecko has no reload
|
||||
# for userChrome.css and Zen exposes no command for one.
|
||||
|
|
@ -97,33 +110,62 @@ let
|
|||
Components.utils.reportError("zen-theme: " + e);
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (lib.elem config.networking.hostName [ "FredOS-Gaming" "FredOS-Macbook" ]) {
|
||||
in {
|
||||
config = lib.mkIf (lib.elem config.networking.hostName ["FredOS-Gaming" "FredOS-Macbook"]) {
|
||||
environment.systemPackages = [
|
||||
((inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
|
||||
# Lands in defaults/pref/autoconfig.js, the only place this pref is
|
||||
# read — setting it from mozilla.cfg is too late to unsandbox itself.
|
||||
extraAutoConfig = ''
|
||||
pref("general.config.sandbox_enabled", false);
|
||||
pref("fred.zenTheme.autoconfig", true);
|
||||
'';
|
||||
extraPrefs = themeHotReload;
|
||||
}).overrideAttrs (old: {
|
||||
# wrapFirefox copies the executable it knows by name so that Gecko,
|
||||
# which derives its application directory from the binary's *resolved*
|
||||
# path, lands in the wrapper's tree. It knows this one as "zen-beta"
|
||||
# (binaryName), but the binary actually exec'd is lib/zen-bin-*/zen —
|
||||
# left behind as a symlink into the unwrapped package. So the app dir
|
||||
# resolved to the unwrapped tree, which has no defaults/pref and no
|
||||
# mozilla.cfg, and every pref and script above was silently skipped.
|
||||
buildCommand = old.buildCommand + ''
|
||||
for exe in "$out"/lib/zen*/zen "$out"/lib/zen*/zen-bin; do
|
||||
cp --remove-destination "$(readlink -f "$exe")" "$exe"
|
||||
chmod u+w "$exe"
|
||||
done
|
||||
'';
|
||||
}))
|
||||
# Lands in defaults/pref/autoconfig.js, the only place this pref is
|
||||
# read — setting it from mozilla.cfg is too late to unsandbox itself.
|
||||
extraAutoConfig = ''
|
||||
pref("general.config.sandbox_enabled", false);
|
||||
pref("fred.zenTheme.autoconfig", true);
|
||||
'';
|
||||
extraPrefs = themeHotReload;
|
||||
}).overrideAttrs (old: {
|
||||
# wrapFirefox copies the executable it knows by name so that Gecko,
|
||||
# which derives its application directory from the binary's *resolved*
|
||||
# path, lands in the wrapper's tree. It knows this one as "zen-beta"
|
||||
# (binaryName), but the binary actually exec'd is lib/zen-bin-*/zen —
|
||||
# left behind as a symlink into the unwrapped package. So the app dir
|
||||
# resolved to the unwrapped tree, which has no defaults/pref and no
|
||||
# mozilla.cfg, and every pref and script above was silently skipped.
|
||||
buildCommand =
|
||||
old.buildCommand
|
||||
+ ''
|
||||
for exe in "$out"/lib/zen*/zen "$out"/lib/zen*/zen-bin; do
|
||||
cp --remove-destination "$(readlink -f "$exe")" "$exe"
|
||||
chmod u+w "$exe"
|
||||
done
|
||||
|
||||
# Zen ships its privileged browser modules inside browser/omni.ja.
|
||||
# Repack that archive with the local Window Sync fix; keeping this as
|
||||
# a normal patch makes an upstream update fail loudly when the source
|
||||
# changes instead of silently dropping the workaround.
|
||||
for omni in "$out"/lib/zen*/browser/omni.ja; do
|
||||
[ -f "$omni" ] || continue
|
||||
cp "$(readlink -f "$omni")" "$omni.local"
|
||||
mv -f "$omni.local" "$omni"
|
||||
|
||||
omniWork="$(mktemp -d)"
|
||||
${pkgs.unzip}/bin/unzip -q "$omni" -d "$omniWork" || {
|
||||
unzipStatus=$?
|
||||
# Mozilla's startup-optimized omnijar places its central
|
||||
# directory first. Info-ZIP extracts it correctly but exits 2
|
||||
# after warning about the nonstandard layout.
|
||||
[ "$unzipStatus" -eq 2 ] || exit "$unzipStatus"
|
||||
}
|
||||
${pkgs.patch}/bin/patch --directory="$omniWork" -p1 \
|
||||
< ${windowSyncPatch}
|
||||
|
||||
rm "$omni"
|
||||
(
|
||||
cd "$omniWork"
|
||||
${pkgs.zip}/bin/zip -0 -X -q -r "$omni" .
|
||||
)
|
||||
rm -rf "$omniWork"
|
||||
done
|
||||
'';
|
||||
}))
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue