Files

179 lines
7.5 KiB
Nix

# ABOUTME: Firefox with its preconfiguration, and Chromium as the second browser.
# ABOUTME: Carries the default-handler registration the two of them make necessary.
{ pkgs, moonarchPkgs, ... }:
let
# The Firefox theme's add-on ID, read twice below: once to install the theme,
# once to select it. This is upstream Catppuccin's own build; the similarly
# named catppuccin-mocha on the same store belongs to a third party.
catppuccinThemeId = "{8446b178-c865-4f5c-8ccc-1d7887811ae3}";
in
{
# Browser. moonarch runs waterfox-bin, which nixpkgs does not carry; see
# DECISIONS.md for why this is not packaged here.
#
# The module puts the wrapped Firefox into environment.systemPackages itself,
# which is why the package list below names only the second browser.
# autoConfigFiles is what carries Betterfox: the wrapper concatenates every
# file named here into mozilla.cfg, which Firefox reads before a profile
# exists — the only way in without home-manager.
programs.firefox = {
enable = true;
languagePacks = [ "de" ];
autoConfigFiles = [ "${moonarchPkgs.betterfox}/user.cfg" ];
# Betterfox rewrites user_pref to defaultPref so that each of its 115 values
# stays changeable in about:config. This option defaults to "locked", which
# would nail these three down harder than the set they sit in.
preferencesStatus = "default";
preferences = {
"general.autoScroll" = true;
"browser.tabs.hoverPreview.showThumbnails" = false;
"browser.nova.enabled" = false;
# Only the offer to translate. Translating by hand from the context menu
# keeps working.
"browser.translations.automaticallyPopup" = false;
# ExtensionSettings installs the theme but does not select it; without
# this, Firefox starts on the default look with Catppuccin sitting unused
# in the add-on manager.
"extensions.activeThemeID" = catppuccinThemeId;
# The two autofill switches in the privacy settings, "Save and fill
# addresses" and "Save and fill payment methods". Each carries a capture
# half as a child preference, so one switch covers both storing and
# filling. Betterfox leaves these alone; Firefox ships them on.
"extensions.formautofill.addresses.enabled" = false;
"extensions.formautofill.creditCards.enabled" = false;
};
# normal_installed rather than force_installed: every add-on stays
# removable. Leaving LibreWolf was about hardening that could only be undone
# by hand.
#
# The latest.xpi URLs redirect to whatever the current version is, so none of
# them needs a version bump here.
policies = {
ExtensionSettings = {
"uBlock0@raymondhill.net" = {
installation_mode = "normal_installed";
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
};
# Bitwarden Inc.'s own build, not one of the third-party forks that
# carry the same name on the store.
"{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
installation_mode = "normal_installed";
install_url = "https://addons.mozilla.org/firefox/downloads/latest/bitwarden-password-manager/latest.xpi";
};
${catppuccinThemeId} = {
installation_mode = "normal_installed";
install_url = "https://addons.mozilla.org/firefox/downloads/latest/catppuccin-mocha-lavender-git/latest.xpi";
};
};
# languagePacks installs the German pack, it does not switch to it — the
# same split as the theme above. Firefox does not derive this from LANG
# either: without the policy the interface stays English with the pack
# sitting installed and active.
RequestedLocales = [ "de" ];
# The three suggestion switches in the search settings. Their preferences
# ship as false and no user value sets them, so something enables them at
# runtime — the policy is what holds against that. From Firefox 146 on,
# WebSuggestions switches Suggest off as a whole; this is 156.
#
# ImproveSuggest is the data collection behind it: what gets typed into
# the address bar goes to Mozilla to improve the suggestions. It is stated
# rather than left to follow from the other two, so it does not come back
# if Suggest is ever turned on again.
FirefoxSuggest = {
WebSuggestions = false;
SponsoredSuggestions = false;
ImproveSuggest = false;
};
# The own search instance, added and made the default. Default only sets
# where Firefox starts; switching in the search settings keeps working.
# No IconURL: the favicon sits behind the Authelia login, so Firefox
# could not fetch it when it applies the policy.
SearchEngines = {
Add = [
{
Name = "moonarch";
URLTemplate = "https://search.moonarch.de/search?q={searchTerms}";
Method = "GET";
Alias = "@m";
}
];
Default = "moonarch";
# Everything Firefox 157 ships for German locale and region, except
# DuckDuckGo and Wikipedia (de). Hidden from the list, not uninstalled;
# names as the search settings show them, a typo is silently ignored.
Remove = [
"Bing"
"eBay"
"Ecosia"
"Google"
"LEO Eng-Deu"
"Perplexity"
"Reddit"
"Startpage"
"YouTube"
];
};
OfferToSaveLogins = false;
# Startup and the home button both land on a blank page. StartPage
# "homepage" is what makes the URL apply to startup as well; "none" would
# reach the same screen but leave the home button pointing elsewhere.
Homepage = {
URL = "about:blank";
StartPage = "homepage";
};
# A new tab opens blank as well, rather than on the Firefox start page
# with its search field and shortcuts.
NewTabPage = false;
# The initial state only — the toolbar stays something you can bring back
# from the View menu. There is no policy that locks it away.
DisplayBookmarksToolbar = "never";
# This is the Sync policy. There is no DisableSync: the CCK2 name of this
# one is disableSync, and it sets identity.fxaccounts.enabled.
DisableFirefoxAccounts = true;
# DisablePocket is deprecated and, by Mozilla's own note, leaves the new
# tab page alone. FirefoxHome covers that half: Stories replaced Pocket
# there in Firefox 141, after the service was discontinued.
DisablePocket = true;
FirefoxHome = {
Stories = false;
SponsoredStories = false;
};
};
};
# Both browsers claim x-scheme-handler/http in their desktop entries, and
# with two candidates xdg-open picks by whatever order it finds them in.
# The first four types are exactly what firefox.desktop declares; PDFs go to
# Firefox's built-in viewer as well.
xdg.mime.defaultApplications = {
"text/html" = "firefox.desktop";
"application/xhtml+xml" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
"application/pdf" = "firefox.desktop";
};
environment.systemPackages = [
# Second browser, for testing against a Blink engine. The ungoogled
# variant because the stock chromium carries the Google endpoints; it is
# fully substitutable, so the patch set does not have to be built here.
# Firefox comes from programs.firefox above and is the default handler.
pkgs.ungoogled-chromium
];
}