programs/firefox: switch from librewolf back to firefox
done such that (1) i can still load unsigned browser extensions and (2) i get all the privacy preferences of LW. at this point staying closer to mainline Firefox means easier debugging, and without much lost
This commit is contained in:
@@ -9,26 +9,24 @@
|
||||
{ config, lib, pkgs, ...}:
|
||||
let
|
||||
cfg = config.sane.programs.firefox.config;
|
||||
librewolf-prefs = pkgs.librewolf-unwrapped.extraPrefsFiles;
|
||||
mobile-prefs = lib.optionals false pkgs.librewolf-pmos-mobile.extraPrefsFiles;
|
||||
# allow easy switching between firefox and librewolf with `defaultSettings`, below
|
||||
librewolfSettings = {
|
||||
browser = pkgs.librewolf-unwrapped;
|
||||
extraPrefsFiles = pkgs.librewolf-unwrapped.extraPrefsFiles ++ mobile-prefs;
|
||||
libName = "librewolf";
|
||||
dotDir = ".librewolf";
|
||||
cacheDir = ".cache/librewolf";
|
||||
desktop = "librewolf.desktop";
|
||||
};
|
||||
firefoxSettings = {
|
||||
browser = pkgs.firefox-esr-unwrapped;
|
||||
extraPrefsFiles = mobile-prefs;
|
||||
# browser = pkgs.firefox-esr-unwrapped;
|
||||
browser = pkgs.firefox-unwrapped;
|
||||
libName = "firefox";
|
||||
dotDir = ".mozilla/firefox";
|
||||
cacheDir = ".cache/mozilla";
|
||||
desktop = "firefox.desktop";
|
||||
};
|
||||
# defaultSettings = firefoxSettings;
|
||||
defaultSettings = librewolfSettings;
|
||||
defaultSettings = firefoxSettings;
|
||||
# defaultSettings = librewolfSettings;
|
||||
|
||||
nativeMessagingHostNames = lib.flatten (
|
||||
lib.mapAttrsToList
|
||||
@@ -56,9 +54,20 @@ let
|
||||
in (pkgs.wrapFirefox unwrapped {
|
||||
# inherit the default librewolf.cfg
|
||||
# it can be further customized via ~/.librewolf/librewolf.overrides.cfg
|
||||
inherit (cfg.browser) extraPrefsFiles libName;
|
||||
inherit (cfg.browser) libName;
|
||||
inherit nativeMessagingHosts;
|
||||
|
||||
# librewolf prefs make a good base to build on regardless of whether using LW or not
|
||||
extraPrefsFiles = librewolf-prefs ++ mobile-prefs ++ [
|
||||
(pkgs.writeText "mozilla.cfg" ''
|
||||
// load additional preferences from user directory; inspired by librewolf
|
||||
let home_dir;
|
||||
if (home_dir = getenv('HOME')) {
|
||||
defaultPref('autoadmin.global_config_url', `file://''${home_dir}/.mozilla/firefox/user.js`);
|
||||
}
|
||||
'')
|
||||
];
|
||||
|
||||
nixExtensions = lib.concatMap (ext: lib.optional ext.enable ext.package) (builtins.attrValues cfg.addons);
|
||||
}).overrideAttrs (base: {
|
||||
nativeBuildInputs = (base.nativeBuildInputs or []) ++ [
|
||||
@@ -222,7 +231,7 @@ in
|
||||
] ++ addonHomePaths;
|
||||
|
||||
mime.associations = let
|
||||
inherit (cfg.browser) desktop;
|
||||
desktop = "${cfg.browser.browser.meta.mainProgram}.desktop";
|
||||
in {
|
||||
"text/html" = desktop;
|
||||
"x-scheme-handler/http" = desktop;
|
||||
@@ -234,110 +243,9 @@ in
|
||||
env.BROWSER = cfg.browser.libName; # used by misc tools like xdg-email, as fallback
|
||||
|
||||
# redirect librewolf configs to the firefox configs; this way addons don't have to care about the firefox/librewolf distinction.
|
||||
fs.".librewolf/librewolf.overrides.cfg".symlink.target = "../.mozilla/firefox/firefox.overrides.cfg";
|
||||
fs.".librewolf/profiles.ini".symlink.target = "../.mozilla/firefox/profiles.ini";
|
||||
fs.".librewolf/managed-storage".symlink.target = "../.mozilla/firefox/managed-storage";
|
||||
|
||||
# N.B.: `overrides.cfg` might be librewolf-specific -- not supported by mainline firefox.
|
||||
# firefox does support per-profile `user.js` files which have similar functionality.
|
||||
# actually, i think this can be expressed in a firefox-compatible manner:
|
||||
# - <https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig>
|
||||
fs.".mozilla/firefox/firefox.overrides.cfg".symlink.text = ''
|
||||
// DEFAULT OPTION VALUES: <https://searchfox.org/mozilla-central/source/modules/libpref/init/all.js>
|
||||
// common tweaks: <https://librewolf.net/docs/settings/>
|
||||
// runtime-modified prefs are stored in ~/.librewolf/default/prefs.js
|
||||
//
|
||||
// use `pref(...)` to force a preference
|
||||
// use `defaultPref(...)` to allow runtime reconfiguration
|
||||
// use `lockPref(...)` to prevent the preferences from being changed at runtime (incl preventing firefox from updating them itself)
|
||||
// discover preference names via the `about:config` page
|
||||
// N.B.: supported option values appear to be:
|
||||
// - string
|
||||
// - bool
|
||||
// - number
|
||||
// anything else (e.g. arrays, objects) MUST be represented as strings (use backticks for multiline/raw strings)
|
||||
|
||||
// if we can't query the revocation status of a SSL cert because the issuer is offline,
|
||||
// treat it as unrevoked.
|
||||
// see: <https://librewolf.net/docs/faq/#im-getting-sec_error_ocsp_server_error-what-can-i-do>
|
||||
defaultPref("security.OCSP.require", false);
|
||||
// kinda weird to send ALL my domain connections to a 3rd party server, just disable OCSP
|
||||
defaultPref("security.OCSP.enabled", 0);
|
||||
|
||||
// DISABLE DNS OVER HTTPS; use the system resolver.
|
||||
defaultPref("network.trr.mode", 5);
|
||||
|
||||
// enable webGL
|
||||
defaultPref("webgl.disabled", false);
|
||||
|
||||
// scrollbar configuration, see: <https://artemis.sh/2023/10/12/scrollbars.html>
|
||||
// style=4 gives rectangular scrollbars
|
||||
// could also enable "always show scrollbars" in about:preferences -- not sure what the actual pref name for that is
|
||||
// note that too-large scrollbars (like 50px wide, even 20px) tend to obscure content (and make buttons unclickable)
|
||||
defaultPref("widget.non-native-theme.scrollbar.size.override", 14);
|
||||
defaultPref("widget.non-native-theme.scrollbar.style", 4);
|
||||
|
||||
// disable inertial/kinetic/momentum scrolling because it just gets in the way on touchpads
|
||||
// source: <https://kparal.wordpress.com/2019/10/31/disabling-kinetic-scrolling-in-firefox/>
|
||||
defaultPref("apz.gtk.kinetic_scroll.enabled", false);
|
||||
|
||||
// uidensity=2 gives more padding around UI elements.
|
||||
// source: <https://codeberg.org/user0/Mobile-Friendly-Firefox>
|
||||
defaultPref("browser.uidensity", 2);
|
||||
// layout.css.devPixelsPerPx: acts as a global scale (even for the chrome)
|
||||
// defaultPref("layout.css.devPixelsPerPx", 1.5);
|
||||
|
||||
// open external URIs/files via xdg-desktop-portal.
|
||||
defaultPref("widget.use-xdg-desktop-portal.mime-handler", 1);
|
||||
defaultPref("widget.use-xdg-desktop-portal.open-uri", 1);
|
||||
|
||||
defaultPref("browser.toolbars.bookmarks.visibility", "never");
|
||||
|
||||
// enable vertical tab view, like Sidebery (but loses the top-window horizontal tabs)
|
||||
// defaultPref("browser.toolbarbuttons.introduced.sidebar-button", true);
|
||||
defaultPref("sidebar.animation.enabled", false);
|
||||
defaultPref("sidebar.backupState", `{"width":"","command":"","expanded":true,"hidden":false}`);
|
||||
defaultPref("sidebar.main.tools", "history");
|
||||
defaultPref("sidebar.revamp", true);
|
||||
defaultPref("sidebar.verticalTabs", true);
|
||||
// vvv default is for tabs button to toggle tab icons v.s. tab icons + description.
|
||||
// "hide-sidebar" => toggle between tab icons + description and NO visibility at all.
|
||||
defaultPref("sidebar.visibility", "hide-sidebar");
|
||||
|
||||
// configure topbar:
|
||||
// placing an item in "seen" marks it as handled; items omitted from "seen" are placed in their default location.
|
||||
// XXX(2024-12-01): the first "sidebar-button" placement is eaten. you MUST specify it at least twice for FF to respect it.
|
||||
defaultPref("browser.uiCustomization.state", `{
|
||||
"placements":{
|
||||
"nav-bar":["firefox-view-button","sidebar-button","sidebar-button","back-button","forward-button","urlbar-container","unified-extensions-button"]
|
||||
},
|
||||
"seen":["ublock0_raymondhill_net-browser-action","sponsorblocker_ajay_app-browser-action"],
|
||||
"currentVersion":20
|
||||
}`);
|
||||
// defaultPref("browser.uiCustomization.horizontalTabstrip", `["firefox-view-button","tabbrowser-tabs"]`);
|
||||
|
||||
// auto-open specific URI schemes without prompting:
|
||||
defaultPref("network.protocol-handler.external.xdg-open", true); // for firefox-xdg-open extension
|
||||
defaultPref("network.protocol-handler.external.mpv", true); // for open-in-mpv extension
|
||||
defaultPref("network.protocol-handler.external.element", true); // for Element matrix client
|
||||
defaultPref("network.protocol-handler.external.matrix", true); // for Nheko matrix client
|
||||
|
||||
// statically configure bookmarks.
|
||||
// notably, these bookmarks have "shortcut url" fields:
|
||||
// - type `w thing` into the URL bar to search "thing" on Wikipedia.
|
||||
// - to add a search shortcut: right-click any search box => "Add a keyword for this search".
|
||||
// - to update the static bookmarks, export via Hamburger => bookmarks => manage bookmarks => Import and Backup => Export Bookmarks To HTML
|
||||
defaultPref("browser.bookmarks.addedImportButton", true);
|
||||
defaultPref("browser.places.importBookmarksHTML", true);
|
||||
defaultPref("browser.bookmarks.file", "~/.mozilla/firefox/bookmarks.html");
|
||||
|
||||
defaultPref("browser.startup.homepage", "https://uninsane.org/places");
|
||||
|
||||
|
||||
// browser.engagement.sidebar-button.has-used
|
||||
// browser.migration.version = 150
|
||||
'';
|
||||
|
||||
fs.".mozilla/firefox/bookmarks.html".symlink.target = ./bookmarks.html;
|
||||
|
||||
# instruct Firefox to put the profile in a predictable directory (so we can do things like persist just it).
|
||||
@@ -353,6 +261,8 @@ in
|
||||
StartWithLastProfile=1
|
||||
'';
|
||||
|
||||
fs.".mozilla/firefox/user.js".symlink.target = ./user.js;
|
||||
|
||||
# flush the cache to disk to avoid it taking up too much tmp.
|
||||
persist.byPath."${cfg.browser.cacheDir}".store =
|
||||
if (cfg.persistData != null) then
|
||||
|
100
hosts/common/programs/firefox/user.js
Normal file
100
hosts/common/programs/firefox/user.js
Normal file
@@ -0,0 +1,100 @@
|
||||
// DEFAULT OPTION VALUES: <https://searchfox.org/mozilla-central/source/modules/libpref/init/all.js>
|
||||
// common tweaks: <https://librewolf.net/docs/settings/>
|
||||
// runtime-modified prefs are stored in ~/.mozilla/firefox/default/prefs.js
|
||||
//
|
||||
// pref overriding is documented lightly here:
|
||||
// - <https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig>
|
||||
//
|
||||
// use `pref(...)` to force a preference
|
||||
// use `defaultPref(...)` to allow runtime reconfiguration
|
||||
// use `lockPref(...)` to prevent the preferences from being changed at runtime (incl preventing firefox from updating them itself)
|
||||
// discover preference names via the `about:config` page
|
||||
// N.B.: supported option values appear to be:
|
||||
// - string
|
||||
// - bool
|
||||
// - number
|
||||
// anything else (e.g. arrays, objects) MUST be represented as strings (use backticks for multiline/raw strings)
|
||||
|
||||
// if we can't query the revocation status of a SSL cert because the issuer is offline,
|
||||
// treat it as unrevoked.
|
||||
// see: <https://librewolf.net/docs/faq/#im-getting-sec_error_ocsp_server_error-what-can-i-do>
|
||||
defaultPref("security.OCSP.require", false);
|
||||
// kinda weird to send ALL my domain connections to a 3rd party server, just disable OCSP
|
||||
defaultPref("security.OCSP.enabled", 0);
|
||||
|
||||
// DISABLE DNS OVER HTTPS; use the system resolver.
|
||||
defaultPref("network.trr.mode", 5);
|
||||
|
||||
// enable webGL
|
||||
defaultPref("webgl.disabled", false);
|
||||
|
||||
// scrollbar configuration, see: <https://artemis.sh/2023/10/12/scrollbars.html>
|
||||
// style=4 gives rectangular scrollbars
|
||||
// could also enable "always show scrollbars" in about:preferences -- not sure what the actual pref name for that is
|
||||
// note that too-large scrollbars (like 50px wide, even 20px) tend to obscure content (and make buttons unclickable)
|
||||
defaultPref("widget.non-native-theme.scrollbar.size.override", 14);
|
||||
defaultPref("widget.non-native-theme.scrollbar.style", 4);
|
||||
|
||||
// disable inertial/kinetic/momentum scrolling because it just gets in the way on touchpads
|
||||
// source: <https://kparal.wordpress.com/2019/10/31/disabling-kinetic-scrolling-in-firefox/>
|
||||
defaultPref("apz.gtk.kinetic_scroll.enabled", false);
|
||||
|
||||
// uidensity=2 gives more padding around UI elements.
|
||||
// source: <https://codeberg.org/user0/Mobile-Friendly-Firefox>
|
||||
defaultPref("browser.uidensity", 2);
|
||||
// layout.css.devPixelsPerPx: acts as a global scale (even for the chrome)
|
||||
// defaultPref("layout.css.devPixelsPerPx", 1.5);
|
||||
|
||||
// open external URIs/files via xdg-desktop-portal.
|
||||
defaultPref("widget.use-xdg-desktop-portal.mime-handler", 1);
|
||||
defaultPref("widget.use-xdg-desktop-portal.open-uri", 1);
|
||||
|
||||
defaultPref("browser.toolbars.bookmarks.visibility", "never");
|
||||
|
||||
// enable vertical tab view, like Sidebery (but loses the top-window horizontal tabs)
|
||||
// defaultPref("browser.toolbarbuttons.introduced.sidebar-button", true);
|
||||
defaultPref("sidebar.animation.enabled", false);
|
||||
defaultPref("sidebar.backupState", `{"width":"","command":"","expanded":true,"hidden":false}`);
|
||||
defaultPref("sidebar.main.tools", "history");
|
||||
defaultPref("sidebar.revamp", true);
|
||||
defaultPref("sidebar.verticalTabs", true);
|
||||
// vvv default is for tabs button to toggle tab icons v.s. tab icons + description.
|
||||
// "hide-sidebar" => toggle between tab icons + description and NO visibility at all.
|
||||
defaultPref("sidebar.visibility", "hide-sidebar");
|
||||
|
||||
// configure topbar:
|
||||
// placing an item in "seen" marks it as handled; items omitted from "seen" are placed in their default location.
|
||||
// XXX(2024-12-01): the first "sidebar-button" placement is eaten. you MUST specify it at least twice for FF to respect it.
|
||||
defaultPref("browser.uiCustomization.state", `{
|
||||
"placements":{
|
||||
"unified-extensions-area": ["browserpass_maximbaz_com-browser-action","ublock0_raymondhill_net-browser-action","sponsorblocker_ajay_app-browser-action","magnolia_12_34-browser-action"],
|
||||
"nav-bar":["firefox-view-button","sidebar-button","sidebar-button","back-button","forward-button","urlbar-container","unified-extensions-button"]
|
||||
},
|
||||
"currentVersion":20
|
||||
}`);
|
||||
// defaultPref("browser.uiCustomization.horizontalTabstrip", `["firefox-view-button","tabbrowser-tabs"]`);
|
||||
// 0 to hide the window close button
|
||||
// 2 to show the window close button (default)
|
||||
defaultPref("browser.tabs.inTitlebar", 0);
|
||||
|
||||
// auto-open specific URI schemes without prompting:
|
||||
defaultPref("network.protocol-handler.external.xdg-open", true); // for firefox-xdg-open extension
|
||||
defaultPref("network.protocol-handler.external.mpv", true); // for open-in-mpv extension
|
||||
defaultPref("network.protocol-handler.external.element", true); // for Element matrix client
|
||||
defaultPref("network.protocol-handler.external.matrix", true); // for Nheko matrix client
|
||||
|
||||
// statically configure bookmarks.
|
||||
// notably, these bookmarks have "shortcut url" fields:
|
||||
// - type `w thing` into the URL bar to search "thing" on Wikipedia.
|
||||
// - to add a search shortcut: right-click any search box => "Add a keyword for this search".
|
||||
// - to update the static bookmarks, export via Hamburger => bookmarks => manage bookmarks => Import and Backup => Export Bookmarks To HTML
|
||||
defaultPref("browser.bookmarks.addedImportButton", true);
|
||||
defaultPref("browser.places.importBookmarksHTML", true);
|
||||
defaultPref("browser.bookmarks.file", "~/.mozilla/firefox/bookmarks.html");
|
||||
|
||||
defaultPref("browser.startup.homepage", "https://uninsane.org/places");
|
||||
|
||||
|
||||
// browser.engagement.sidebar-button.has-used
|
||||
// browser.migration.version = 150
|
||||
|
Reference in New Issue
Block a user