2022-10-21 15:38:20 +00:00
|
|
|
# common settings to toggle (at runtime, in about:config):
|
|
|
|
# > security.ssl.require_safe_negotiation
|
|
|
|
|
|
|
|
# librewolf is a forked firefox which patches firefox to allow more things
|
|
|
|
# (like default search engines) to be configurable at runtime.
|
|
|
|
# many of the settings below won't have effect without those patches.
|
|
|
|
# see: https://gitlab.com/librewolf-community/settings/-/blob/master/distribution/policies.json
|
|
|
|
|
2023-05-08 21:41:02 +00:00
|
|
|
{ config, lib, pkgs, ...}:
|
2022-11-01 23:23:50 +00:00
|
|
|
with lib;
|
2022-10-21 15:38:20 +00:00
|
|
|
let
|
2023-07-15 08:51:36 +00:00
|
|
|
cfg = config.sane.programs.firefox.config;
|
2023-07-16 12:25:12 +00:00
|
|
|
mobile-prefs = lib.optionals false pkgs.librewolf-pmos-mobile.extraPrefsFiles;
|
2022-11-01 23:23:50 +00:00
|
|
|
# allow easy switching between firefox and librewolf with `defaultSettings`, below
|
2022-11-01 11:58:45 +00:00
|
|
|
librewolfSettings = {
|
2022-11-02 09:39:56 +00:00
|
|
|
browser = pkgs.librewolf-unwrapped;
|
2023-07-16 12:25:12 +00:00
|
|
|
extraPrefsFiles = pkgs.librewolf-unwrapped.extraPrefsFiles ++ mobile-prefs;
|
2022-11-01 11:58:45 +00:00
|
|
|
libName = "librewolf";
|
|
|
|
dotDir = ".librewolf";
|
2023-06-26 10:11:22 +00:00
|
|
|
cacheDir = ".cache/librewolf";
|
2022-11-01 23:23:50 +00:00
|
|
|
desktop = "librewolf.desktop";
|
2022-11-01 11:58:45 +00:00
|
|
|
};
|
|
|
|
firefoxSettings = {
|
|
|
|
browser = pkgs.firefox-esr-unwrapped;
|
2023-07-16 12:25:12 +00:00
|
|
|
extraPrefsFiles = mobile-prefs;
|
2022-11-01 11:58:45 +00:00
|
|
|
libName = "firefox";
|
|
|
|
dotDir = ".mozilla/firefox";
|
2023-01-04 13:27:20 +00:00
|
|
|
cacheDir = ".cache/mozilla";
|
2022-11-01 23:23:50 +00:00
|
|
|
desktop = "firefox.desktop";
|
2022-11-01 11:58:45 +00:00
|
|
|
};
|
2023-04-14 07:14:50 +00:00
|
|
|
# defaultSettings = firefoxSettings;
|
|
|
|
defaultSettings = librewolfSettings;
|
2022-11-01 11:58:45 +00:00
|
|
|
|
2023-01-26 23:17:06 +00:00
|
|
|
addon = name: extid: hash: pkgs.fetchFirefoxAddon {
|
|
|
|
inherit name hash;
|
|
|
|
url = "https://addons.mozilla.org/firefox/downloads/latest/${name}/latest.xpi";
|
|
|
|
# extid can be found by unar'ing the above xpi, and copying browser_specific_settings.gecko.id field
|
|
|
|
fixedExtid = extid;
|
|
|
|
};
|
|
|
|
localAddon = pkg: pkgs.fetchFirefoxAddon {
|
|
|
|
inherit (pkg) name;
|
|
|
|
src = "${pkg}/share/mozilla/extensions/\\{ec8030f7-c20a-464f-9b0e-13a3a9e97384\\}/${pkg.extid}.xpi";
|
|
|
|
fixedExtid = pkg.extid;
|
|
|
|
};
|
|
|
|
|
2023-01-06 16:11:06 +00:00
|
|
|
package = pkgs.wrapFirefox cfg.browser.browser {
|
2022-10-21 15:38:20 +00:00
|
|
|
# inherit the default librewolf.cfg
|
|
|
|
# it can be further customized via ~/.librewolf/librewolf.overrides.cfg
|
2023-06-26 23:22:45 +00:00
|
|
|
inherit (cfg.browser) extraPrefsFiles libName;
|
2022-10-26 14:13:55 +00:00
|
|
|
|
2023-05-24 23:09:05 +00:00
|
|
|
extraNativeMessagingHosts = optional cfg.addons.browserpass-extension.enable pkgs.browserpass;
|
2022-10-26 14:13:55 +00:00
|
|
|
# extraNativeMessagingHosts = [ pkgs.gopass-native-messaging-host ];
|
|
|
|
|
2023-01-26 23:30:56 +00:00
|
|
|
nixExtensions = concatMap (ext: optional ext.enable ext.package) (attrValues cfg.addons);
|
2022-11-01 11:58:45 +00:00
|
|
|
|
2022-10-21 15:38:20 +00:00
|
|
|
extraPolicies = {
|
2023-05-25 01:01:34 +00:00
|
|
|
FirefoxHome = {
|
|
|
|
Search = true;
|
|
|
|
Pocket = false;
|
|
|
|
Snippets = false;
|
|
|
|
TopSites = false;
|
|
|
|
Highlights = false;
|
|
|
|
};
|
2022-10-21 15:38:20 +00:00
|
|
|
NoDefaultBookmarks = true;
|
2023-05-25 01:01:34 +00:00
|
|
|
OfferToSaveLogins = false;
|
|
|
|
OfferToSaveLoginsDefault = false;
|
|
|
|
PasswordManagerEnabled = false;
|
2022-10-21 15:38:20 +00:00
|
|
|
SearchEngines = {
|
|
|
|
Default = "DuckDuckGo";
|
|
|
|
};
|
2023-05-25 01:01:34 +00:00
|
|
|
UserMessaging = {
|
|
|
|
ExtensionRecommendations = false;
|
2023-06-26 10:11:22 +00:00
|
|
|
FeatureRecommendations = false;
|
2023-05-25 01:01:34 +00:00
|
|
|
SkipOnboarding = true;
|
2023-06-26 10:11:22 +00:00
|
|
|
UrlbarInterventions = false;
|
|
|
|
WhatsNew = false;
|
2023-05-25 01:01:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# these were taken from Librewolf
|
2022-10-21 15:38:20 +00:00
|
|
|
AppUpdateURL = "https://localhost";
|
|
|
|
DisableAppUpdate = true;
|
|
|
|
OverrideFirstRunPage = "";
|
|
|
|
OverridePostUpdatePage = "";
|
|
|
|
DisableSystemAddonUpdate = true;
|
|
|
|
DisableFirefoxStudies = true;
|
|
|
|
DisableTelemetry = true;
|
|
|
|
DisableFeedbackCommands = true;
|
|
|
|
DisablePocket = true;
|
|
|
|
DisableSetDesktopBackground = false;
|
2022-11-01 11:58:45 +00:00
|
|
|
|
2022-11-02 02:29:33 +00:00
|
|
|
# remove many default search providers
|
|
|
|
# XXX this seems to prevent the `nixExtensions` from taking effect
|
|
|
|
# Extensions.Uninstall = [
|
|
|
|
# "google@search.mozilla.org"
|
|
|
|
# "bing@search.mozilla.org"
|
|
|
|
# "amazondotcom@search.mozilla.org"
|
|
|
|
# "ebay@search.mozilla.org"
|
|
|
|
# "twitter@search.mozilla.org"
|
|
|
|
# ];
|
2022-10-21 15:38:20 +00:00
|
|
|
# XXX doesn't seem to have any effect...
|
|
|
|
# docs: https://github.com/mozilla/policy-templates#homepage
|
|
|
|
# Homepage = {
|
|
|
|
# HomepageURL = "https://uninsane.org/";
|
|
|
|
# StartPage = "homepage";
|
|
|
|
# };
|
|
|
|
# NewTabPage = true;
|
|
|
|
};
|
2023-05-25 01:01:34 +00:00
|
|
|
# extraPrefs = ...
|
2022-10-21 15:38:20 +00:00
|
|
|
};
|
2023-01-26 23:30:56 +00:00
|
|
|
|
|
|
|
addonOpts = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-08 09:49:58 +00:00
|
|
|
configOpts = {
|
|
|
|
options = {
|
|
|
|
browser = mkOption {
|
|
|
|
default = defaultSettings;
|
|
|
|
type = types.anything;
|
|
|
|
};
|
|
|
|
persistData = mkOption {
|
|
|
|
description = "optional store name to which persist browsing data (like history)";
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
persistCache = mkOption {
|
|
|
|
description = "optional store name to which persist browser cache";
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "cryptClearOnBoot";
|
|
|
|
};
|
|
|
|
addons = mkOption {
|
|
|
|
type = types.attrsOf addonOpts;
|
2023-05-24 23:09:05 +00:00
|
|
|
default = {};
|
2023-01-26 23:30:56 +00:00
|
|
|
};
|
|
|
|
};
|
2022-11-01 23:23:50 +00:00
|
|
|
};
|
2023-05-08 09:49:58 +00:00
|
|
|
in
|
|
|
|
{
|
2023-04-26 00:52:13 +00:00
|
|
|
config = mkMerge [
|
2023-05-08 09:49:58 +00:00
|
|
|
({
|
2023-07-15 08:51:36 +00:00
|
|
|
sane.programs.firefox.configOption = mkOption {
|
2023-05-08 09:49:58 +00:00
|
|
|
type = types.submodule configOpts;
|
|
|
|
default = {};
|
|
|
|
};
|
2023-07-15 08:51:36 +00:00
|
|
|
sane.programs.firefox.config.addons = {
|
2023-05-24 23:09:05 +00:00
|
|
|
browserpass-extension = {
|
2023-07-17 21:32:10 +00:00
|
|
|
package = pkgs.firefox-extensions.browserpass-extension;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
2023-07-18 20:21:48 +00:00
|
|
|
bypass-paywalls-clean = {
|
|
|
|
package = pkgs.firefox-extensions.bypass-paywalls-clean;
|
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
2023-05-24 23:09:05 +00:00
|
|
|
ether-metamask = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.ether-metamask;
|
2023-07-17 21:33:15 +00:00
|
|
|
enable = lib.mkDefault false; # until i can disable the first-run notification
|
2023-05-24 23:09:05 +00:00
|
|
|
};
|
|
|
|
i2p-in-private-browsing = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.i2p-in-private-browsing;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault config.services.i2p.enable;
|
|
|
|
};
|
|
|
|
sidebery = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.sidebery;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
|
|
|
sponsorblock = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.sponsorblock;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
|
|
|
ublacklist = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.ublacklist;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
|
|
|
ublock-origin = {
|
2023-07-17 03:11:08 +00:00
|
|
|
package = pkgs.firefox-extensions.ublock-origin;
|
2023-05-24 23:09:05 +00:00
|
|
|
enable = lib.mkDefault true;
|
|
|
|
};
|
|
|
|
};
|
2023-05-08 09:49:58 +00:00
|
|
|
})
|
2023-04-26 00:52:13 +00:00
|
|
|
({
|
2023-07-15 08:51:36 +00:00
|
|
|
sane.programs.firefox = {
|
2023-04-26 00:52:13 +00:00
|
|
|
inherit package;
|
2023-01-06 16:11:06 +00:00
|
|
|
|
2023-07-15 10:04:22 +00:00
|
|
|
mime.associations = let
|
2023-07-15 08:44:18 +00:00
|
|
|
inherit (cfg.browser) desktop;
|
|
|
|
in {
|
|
|
|
"text/html" = desktop;
|
|
|
|
"x-scheme-handler/http" = desktop;
|
|
|
|
"x-scheme-handler/https" = desktop;
|
|
|
|
"x-scheme-handler/about" = desktop;
|
|
|
|
"x-scheme-handler/unknown" = desktop;
|
|
|
|
};
|
|
|
|
|
2023-06-30 08:50:58 +00:00
|
|
|
# env.BROWSER = "${package}/bin/${cfg.browser.libName}";
|
|
|
|
env.BROWSER = cfg.browser.libName; # used by misc tools like xdg-email, as fallback
|
|
|
|
|
2023-04-26 00:52:13 +00:00
|
|
|
# uBlock filter list configuration.
|
|
|
|
# specifically, enable the GDPR cookie prompt blocker.
|
|
|
|
# data.toOverwrite.filterLists is additive (i.e. it supplements the default filters)
|
|
|
|
# this configuration method is documented here:
|
|
|
|
# - <https://github.com/gorhill/uBlock/issues/2986#issuecomment-364035002>
|
|
|
|
# the specific attribute path is found via scraping ublock code here:
|
|
|
|
# - <https://github.com/gorhill/uBlock/blob/master/src/js/storage.js>
|
|
|
|
# - <https://github.com/gorhill/uBlock/blob/master/assets/assets.json>
|
2023-05-08 21:41:02 +00:00
|
|
|
fs."${cfg.browser.dotDir}/managed-storage/uBlock0@raymondhill.net.json".symlink.text = ''
|
2023-04-26 00:52:13 +00:00
|
|
|
{
|
|
|
|
"name": "uBlock0@raymondhill.net",
|
|
|
|
"description": "ignored",
|
|
|
|
"type": "storage",
|
|
|
|
"data": {
|
|
|
|
"toOverwrite": "{\"filterLists\": [\"fanboy-cookiemonster\"]}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
2023-06-27 08:09:58 +00:00
|
|
|
# TODO: this is better suited in `extraPrefs` during `wrapFirefox` call
|
2023-05-08 21:41:02 +00:00
|
|
|
fs."${cfg.browser.dotDir}/${cfg.browser.libName}.overrides.cfg".symlink.text = ''
|
2023-04-26 00:52:13 +00:00
|
|
|
// 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);
|
|
|
|
'';
|
2023-05-08 21:41:02 +00:00
|
|
|
fs."${cfg.browser.dotDir}/default".dir = {};
|
2023-04-26 00:52:13 +00:00
|
|
|
# instruct Firefox to put the profile in a predictable directory (so we can do things like persist just it).
|
|
|
|
# XXX: the directory *must* exist, even if empty; Firefox will not create the directory itself.
|
2023-05-08 21:41:02 +00:00
|
|
|
fs."${cfg.browser.dotDir}/profiles.ini".symlink.text = ''
|
2023-04-26 00:52:13 +00:00
|
|
|
[Profile0]
|
|
|
|
Name=default
|
|
|
|
IsRelative=1
|
|
|
|
Path=default
|
|
|
|
Default=1
|
2023-01-27 01:52:00 +00:00
|
|
|
|
2023-04-26 00:52:13 +00:00
|
|
|
[General]
|
|
|
|
StartWithLastProfile=1
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
2023-07-15 08:51:36 +00:00
|
|
|
(mkIf config.sane.programs.firefox.enabled {
|
2023-04-26 00:52:13 +00:00
|
|
|
# TODO: move the persistence into the sane.programs API (above)
|
2023-07-13 06:44:22 +00:00
|
|
|
# flush the cache to disk to avoid it taking up too much tmp.
|
|
|
|
sane.user.persist.byPath."${cfg.browser.cacheDir}".store =
|
|
|
|
if (cfg.persistData != null) then
|
|
|
|
cfg.persistData
|
|
|
|
else
|
|
|
|
"cryptClearOnBoot"
|
|
|
|
;
|
2023-01-27 01:52:00 +00:00
|
|
|
|
2023-07-13 06:44:22 +00:00
|
|
|
sane.user.persist.byPath."${cfg.browser.dotDir}/default".store =
|
|
|
|
if (cfg.persistData != null) then
|
|
|
|
cfg.persistData
|
|
|
|
else
|
|
|
|
"cryptClearOnBoot"
|
|
|
|
;
|
2023-04-26 00:52:13 +00:00
|
|
|
})
|
|
|
|
];
|
2022-10-21 15:38:20 +00:00
|
|
|
}
|