patch Firefox so that we can properly set the default search engine

i'll probably (partially) revert this and switch to librewolf instead.
Firefox takes about 1hr to build.
This commit is contained in:
colin 2022-07-01 01:04:19 -07:00
parent 1e33b1acb8
commit ce5431591c
4 changed files with 82 additions and 5 deletions

View File

@ -143,9 +143,66 @@ in
'';
};
# librewolf is able to set the default search engine by using mozilla policies.
# they do this by removing the "enterprise" gate on some features and building a patched Firefox.
# some of the settings below assume those patches have been applied to firefox.
# see: https://gitlab.com/librewolf-community/settings/-/blob/master/distribution/policies.json
firefox = lib.mkIf (sysconfig.colinsane.gui.enable) {
enable = true;
# https://discourse.nixos.org/t/infinite-recursion-with-wrapfirefox/11579
package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
extraPolicies = {
DisableAppUpdate = true;
DisablePocket = true;
DisableFirefoxStudies = true;
DisableTelemetry = true;
DisableFeedbackCommands = true;
Extensions = {
Uninstall = [
"google@search.mozilla.org"
"bing@search.mozilla.org"
"amazondotcom@search.mozilla.org"
"ebay@search.mozilla.org"
"twitter@search.mozilla.org"
];
};
SearchEngines = {
Default = "DuckDuckGo";
Remove = [
"Google"
"Bing"
"Amazon.com"
"eBay"
"Twitter"
];
Add = [
{
Name = "DuckDuckGo Lite";
Description = "Minimal, ad-free version of DuckDuckGo";
Alias = "";
Method = "POST";
URLTemplate = "https://duckduckgo.com/lite/?q={searchTerms}";
PostData = "q={searchTerms}";
}
];
};
};
extraPrefs = ''
lockPref("devtools.theme","dark");
lockPref("browser.search.defaultenginename","DuckDuckGo");
lockPref("browser.search.selectedEngine","DuckDuckGo");
lockPref("browser.search.defaulturl","https://duckduckgo.com/?q=");
lockPref("browser.search.searchEnginesURL","https://duckduckgo.com/?q=");
lockPref("browser.search.selectedEngineInDialog","DuckDuckGo");
lockPref("browser.search.hiddenOneOffs","Google,eBay,Yahoo,Bing,Amazon.com,Twitter");
lockPref("browser.search.update",false);
lockPref("browser.urlbar.update2.engineAliasRefresh",false);
lockPref("browser.urlbar.update2.oneOffsRefresh",false);
'';
};
profiles.default = {
bookmarks = {
fed_uninsane.url = "https://fed.uninsane.org/";
@ -156,11 +213,6 @@ in
};
};
# firefox profile support seems to be broken :shrug:
# profiles.other = {
# id = 2;
# };
# NB: these must be manually enabled in the Firefox settings on first start
# extensions can be found here: https://gitlab.com/rycee/nur-expressions/-/blob/master/pkgs/firefox-addons/addons.json
extensions = let

View File

@ -0,0 +1,13 @@
diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json
index d436cf1ca1..ecd6e53b9e 100644
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -1074,7 +1074,7 @@
},
"SearchEngines": {
- "enterprise_only": true,
+ "enterprise_only": false,
"type": "object",
"properties": {

View File

@ -0,0 +1,10 @@
{ pkgs }:
(pkgs.firefox-unwrapped.overrideAttrs (upstream: {
# NB: firefox takes about 1hr to build on my 24-thread ryzen desktop
patches = (upstream.patches or []) ++ [
# see https://gitlab.com/librewolf-community/browser/source/-/blob/main/patches/sed-patches/allow-searchengines-non-esr.patch
./allow-searchengines-non-esr.patch
];
}))

View File

@ -18,6 +18,8 @@
pleroma = prev.callPackage ./pleroma { };
# jackett doesn't allow customization of the bind address: this will probably always be here.
jackett = prev.callPackage ./jackett { pkgs = prev; };
# mozilla keeps nerfing itself and removing configuration options
firefox-unwrapped = prev.callPackage ./firefox-unwrapped { pkgs = prev; };
# fix abrupt HDD poweroffs as during reboot. patching systemd requires rebuilding nearly every package.
# systemd = import ./pkgs/systemd { pkgs = prev; };