Skip to content

Commit 21a7276

Browse files
authored
fix(darwin): use stable app path to prevent installs.ini accumulation (#150)
* fix: Add policies.json support for macOS (Darwin) Previously, policies.json was only installed for Linux builds, causing browser policies (including ExtensionSettings) to be ignored on macOS. This resulted in extensions not being automatically installed on macOS systems. This fix adds the policies.json installation to the Darwin install phase, mirroring the Linux behavior and ensuring policy enforcement works correctly on macOS. Fixes extension auto-installation and other policy-based features on macOS. * fix(darwin): use stable app path to prevent installs.ini accumulation Problem: - Zen Browser creates install IDs based on the application path - Wrapper script uses Nix store path which changes on every rebuild - Each new path creates a new install ID entry in installs.ini - Results in: multiple Dock icons, empty profiles, data loss Solution: - Use the stable Home Manager symlink path (~/.../Home Manager Apps/...) - This path remains constant across Nix rebuilds - Zen Browser sees the same path every time, reuses existing install ID - Falls back to store path if symlink doesn't exist yet Benefits: - No activation scripts or workarounds needed - Fixes root cause instead of symptoms - Maintains profile continuity naturally - Clean, elegant solution * fix: force WAL checkpoint after updating places.sqlite Problem: - SQLite WAL mode writes changes to .sqlite-wal file first - Changes aren't visible until WAL is checkpointed to main file - Zen Browser reads stale data from main file on startup - User needs to wait or manually trigger checkpoint to see updates Solution: - Execute PRAGMA wal_checkpoint(FULL) after all updates - Forces immediate merge of WAL changes to main database file - Ensures spaces/pins updates are visible on next Zen startup This fixes the delay between home-manager rebuild and seeing configuration changes in Zen Browser. * fix(darwin): preserve correct bundle identifier in code signature Problem: - AdGuard recognizes apps by code signing identifier, not CFBundleIdentifier - Nix's adhoc re-signing changes identifier from 'app.zen-browser.zen' to 'zen' - This breaks AdGuard's app filtering for Nix-built Zen Browser Solution: - Explicitly set --identifier flag when re-signing with codesign - Maintains 'app.zen-browser.zen' identifier for AdGuard compatibility - Ensures proper ad-blocking and app recognition This allows AdGuard and other security tools to correctly identify Zen Browser even when built through Nix.
1 parent e03039c commit 21a7276

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

hm-module.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ in {
612612
${optionalString (profile.spacesForce) deleteSpaces}
613613
${optionalString (profile.pins != {}) insertPins}
614614
${optionalString (profile.pinsForce) deletePins}
615+
616+
# Force WAL checkpoint to ensure changes are visible immediately
617+
${sqlite3} "${placesFile}" "PRAGMA wal_checkpoint(FULL);" || exit 1
615618
}
616619
617620
error="$(update_places 2>&1 1>/dev/null)"

package.nix

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,24 @@
7171
mkdir -p "$out/Applications/${applicationName}.app/Contents/Resources/distribution"
7272
ln -s ${policiesJson} "$out/Applications/${applicationName}.app/Contents/Resources/distribution/policies.json"
7373
74+
# Re-sign with correct identifier to maintain AdGuard compatibility
75+
# AdGuard uses code signing identifier (not CFBundleIdentifier) to recognize apps
76+
/usr/bin/codesign --force --deep --sign - \
77+
--identifier "app.zen-browser.zen" \
78+
"$out/Applications/${applicationName}.app"
79+
80+
# Use symlink path to avoid installs.ini accumulation on Nix rebuilds
81+
# The symlink is created by home-manager and remains stable across rebuilds
7482
cat > "$out/bin/${binaryName}" << EOF
7583
#!/bin/bash
76-
exec /usr/bin/open -na "$out/Applications/${applicationName}.app" --args "\$@"
84+
# Use stable path from home-manager to avoid creating new install IDs
85+
STABLE_PATH="\$HOME/Applications/Home Manager Apps/${applicationName}.app"
86+
if [[ -e "\$STABLE_PATH" ]]; then
87+
exec /usr/bin/open -na "\$STABLE_PATH" --args "\$@"
88+
else
89+
# Fallback to nix store path if symlink doesn't exist yet
90+
exec /usr/bin/open -na "$out/Applications/${applicationName}.app" --args "\$@"
91+
fi
7792
EOF
7893
7994
chmod +x "$out/bin/${binaryName}"

0 commit comments

Comments
 (0)