nixos-config/home/browsers/firefox.nix

133 lines
4.1 KiB
Nix
Raw Normal View History

{ config, nixosConfig, pkgs, lib, ... }:
2020-08-15 02:30:01 +02:00
with lib;
let
firefox-addons = pkgs.nur.repos.rycee.firefox-addons;
2020-08-15 02:30:01 +02:00
2020-10-03 16:48:01 +02:00
prefer-dark-theme =
config.gtk.gtk3.extraConfig.gtk-application-prefer-dark-theme;
2020-08-15 02:30:01 +02:00
sharedSettings = {
# Privacy & Security Improvements
"browser.contentblocking.category" = "strict";
2020-08-15 02:30:01 +02:00
"browser.urlbar.speculativeConnect.enabled" = false;
2020-11-22 17:02:48 +01:00
"dom.security.https_only_mode" = true;
"media.eme.enabled" = false; # disables DRM
# causes CORS error on waves.exchange when set to 2
"network.http.referer.XOriginPolicy" = 1;
2020-08-15 02:30:01 +02:00
"network.http.referer.XOriginTrimmingPolicy" = 2;
"network.IDN_show_punycode" = true;
# forces ui.systemUsesDarkTheme to false
# "privacy.resistFingerprinting" = true;
# "webgl.disabled" = true;
2020-08-15 02:30:01 +02:00
2021-05-11 20:58:03 +02:00
# Disable DNS over HTTPS (done system-wide)
"network.trr.mode" = 5;
2020-08-15 02:30:01 +02:00
# Theme
2021-06-03 11:46:58 +02:00
"browser.theme.toolbar-theme" = 0;
"ui.systemUsesDarkTheme" = prefer-dark-theme;
2020-10-03 16:48:01 +02:00
"extensions.activeThemeID" = concatStrings [
"firefox-compact-"
(if prefer-dark-theme then "dark" else "light")
"@mozilla.org"
];
"devtools.theme" = if prefer-dark-theme then "dark" else "light";
# i18n
"intl.accept_languages" = "en-GB, en";
"intl.regional_prefs.use_os_locales" = true;
2020-08-25 21:34:43 +02:00
2020-12-25 12:01:55 +01:00
# dev tools
"devtools.inspector.color-scheme-simulation.enabled" = true;
"devtools.inspector.showAllAnonymousContent" = true;
2020-08-25 21:34:43 +02:00
# Other
"browser.startup.page" = 3;
2021-03-04 15:08:34 +01:00
"browser.toolbars.bookmarks.visibility" = "newtab";
2020-08-27 23:39:29 +02:00
"browser.tabs.drawInTitlebar" = true;
"browser.aboutConfig.showWarning" = false;
"signon.rememberSignons" = false;
"services.sync.engine.passwords" = false;
2020-08-28 13:44:06 +02:00
"browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons" = false;
2020-10-03 16:48:01 +02:00
"browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features" =
false;
2020-09-07 12:52:36 +02:00
"browser.newtabpage.activity-stream.feeds.snippets" = false;
2020-11-22 10:55:35 +01:00
"extensions.update.enabled" = false;
"extensions.update.autoUpdateDefault" = false;
} // optionalAttrs nixosConfig.services.mullvad-vpn.enable {
# Mullvad SOCKS proxy
"network.proxy.type" = 1;
"network.proxy.socks" = "10.64.0.1";
"network.proxy.socks_port" = 1080;
"network.proxy.socks_remote_dns" = true;
"network.proxy.no_proxies_on" = "192.168.1.1/24";
2020-08-15 02:30:01 +02:00
};
2020-10-03 16:48:01 +02:00
in {
programs.firefox = {
enable = true;
2022-01-01 02:09:58 +01:00
package = with pkgs; wrapFirefox firefox-unwrapped { forceWayland = true; };
profiles = {
private = {
id = 0;
2020-08-15 02:30:01 +02:00
settings = sharedSettings;
};
work = {
id = 1;
2020-08-15 02:30:01 +02:00
settings = sharedSettings;
};
};
extensions = with firefox-addons; [
ublock-origin
2020-09-07 12:52:36 +02:00
terms-of-service-didnt-read
vimium
ipfs-companion
2020-09-23 09:33:49 +02:00
bitwarden
darkreader
languagetool
metamask
2021-03-04 15:08:34 +01:00
privacy-redirect
2021-06-10 11:54:38 +02:00
to-deepl
2020-08-25 21:34:43 +02:00
# not available yet:
2020-09-07 12:52:36 +02:00
# google-lighthouse
];
};
2020-08-15 02:32:23 +02:00
2020-08-25 21:34:43 +02:00
home.packages = let
makeFirefoxProfileBin = args@{ profile, ... }:
2020-08-25 21:34:43 +02:00
let
name = "firefox-${profile}";
scriptBin = pkgs.writeScriptBin name ''
firefox -P "${profile}" --name="${name}" $@
2020-10-03 16:48:01 +02:00
'';
desktopFile = pkgs.makeDesktopItem ((removeAttrs args [ "profile" ])
// {
inherit name;
exec = "${scriptBin}/bin/${name} %U";
2022-03-05 11:38:53 +01:00
extraConfig.StartupWMClass = name;
genericName = "Web Browser";
2022-03-05 11:38:53 +01:00
mimeTypes = [
"text/html"
"text/xml"
"application/xhtml+xml"
"application/vnd.mozilla.xul+xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
];
2022-03-05 11:38:53 +01:00
categories = [ "Network" "WebBrowser" ];
});
in pkgs.runCommand name { } ''
mkdir -p $out/{bin,share}
cp -r ${scriptBin}/bin/${name} $out/bin/${name}
cp -r ${desktopFile}/share/applications $out/share/applications
'';
2022-01-01 02:13:02 +01:00
in with pkgs; [
(tor-browser-bundle-bin.override { pulseaudioSupport = true; })
(makeFirefoxProfileBin {
profile = "work";
desktopName = "Firefox (Work)";
icon = "firefox";
})
];
}