135 lines
4.1 KiB
Nix
135 lines
4.1 KiB
Nix
{
|
|
config,
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
# Configures Firefox as the desktop browser.
|
|
let
|
|
cfg = config.modules.desktop.apps.firefox; # NOLINT(let_order)
|
|
in
|
|
{
|
|
options.modules.desktop.apps.firefox = {
|
|
enable = lib.mkEnableOption "Firefox as the desktop browser";
|
|
|
|
uiScale = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "1.0";
|
|
description = ''
|
|
Scales Firefox UI and page content.
|
|
|
|
Sets `layout.css.devPixelsPerPx`.
|
|
Use a larger value for high-DPI displays.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
registry.window-icon.${config.networking.hostName}.firefox = {
|
|
class = ".*[Ff]irefox.*";
|
|
icon = builtins.fromJSON ''"\uf269"'';
|
|
};
|
|
|
|
home-manager.users.${config.user.name} = hm: {
|
|
programs.firefox = {
|
|
enable = true;
|
|
|
|
# Applies policies that users cannot change in Firefox.
|
|
policies = {
|
|
DisableTelemetry = true;
|
|
DisableFirefoxStudies = true;
|
|
DisablePocket = true;
|
|
OfferToSaveLogins = false;
|
|
DontCheckDefaultBrowser = true;
|
|
DisableFirefoxAccounts = true;
|
|
|
|
# Removes sponsored content from the new-tab page.
|
|
FirefoxHome = {
|
|
SponsoredTopSites = false;
|
|
SponsoredPocket = false;
|
|
Snippets = false;
|
|
};
|
|
};
|
|
|
|
profiles.default = {
|
|
extensions = {
|
|
packages = with inputs.firefox-addons.packages.${pkgs.stdenv.hostPlatform.system}; [
|
|
ublock-origin
|
|
proton-pass
|
|
sponsorblock
|
|
];
|
|
|
|
# Home Manager overwrites Nord theme changes made in Firefox.
|
|
force = true;
|
|
};
|
|
|
|
# Stylix uses a near-white selection background.
|
|
# Use the Nord selection color because its text stays readable.
|
|
extensions.settings."FirefoxColor@mozilla.com".settings.theme.colors.popup_highlight =
|
|
let
|
|
c = hm.config.lib.stylix.colors;
|
|
in
|
|
lib.mkForce {
|
|
r = c."base03-rgb-r";
|
|
g = c."base03-rgb-g";
|
|
b = c."base03-rgb-b";
|
|
};
|
|
|
|
settings = {
|
|
"layout.css.devPixelsPerPx" = cfg.uiScale;
|
|
|
|
# Enables Firefox Color after Firefox sideloads the add-on.
|
|
"extensions.autoDisableScopes" = 0;
|
|
|
|
# Removes sponsored content outside Firefox policies.
|
|
"browser.urlbar.suggest.quicksuggest.sponsored" = false;
|
|
"browser.newtabpage.activity-stream.showSponsored" = false;
|
|
"browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
|
|
};
|
|
|
|
search = {
|
|
# Home Manager replaces the engine list when this setting is enabled.
|
|
# Engines added in Firefox do not survive a rebuild.
|
|
force = true;
|
|
default = "ddg";
|
|
|
|
# Hides commercial search engines.
|
|
# Bangs still reach these engines.
|
|
# Entries with only `metaData` configure Firefox built-in engines.
|
|
engines = {
|
|
google.metaData.hidden = true;
|
|
bing.metaData.hidden = true;
|
|
ebay.metaData.hidden = true;
|
|
"amazondotcom-us".metaData.hidden = true;
|
|
};
|
|
order = [ "ddg" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
# Applies the Nord theme through Stylix's Firefox Color add-on.
|
|
stylix.targets.firefox = {
|
|
enable = true;
|
|
profileNames = [ "default" ];
|
|
colorTheme.enable = true;
|
|
};
|
|
|
|
# Links opened from other applications land in Firefox.
|
|
xdg.mimeApps = {
|
|
enable = true;
|
|
defaultApplications = {
|
|
"text/html" = "firefox.desktop";
|
|
"application/xhtml+xml" = "firefox.desktop";
|
|
"x-scheme-handler/http" = "firefox.desktop";
|
|
"x-scheme-handler/https" = "firefox.desktop";
|
|
};
|
|
};
|
|
|
|
# Firefox creates `profiles.ini` on its first launch.
|
|
# Force replacement during Home Manager activation.
|
|
home.file."${hm.config.programs.firefox.configPath}/profiles.ini".force = true;
|
|
};
|
|
};
|
|
}
|