Files
moonix/modules/browsers.nix
T
nevaforget dba33d2463 refactor(modules): one topic per module, and Firefox preconfigured
Two changes that cannot be separated in the result: the Firefox
preconfiguration is what made desktop.nix untenable, and the split is what it
now lives in.

Firefox replaces LibreWolf, with Betterfox as its preference base and the
settings that Betterfox does not cover expressed as policies: uBlock Origin,
the Catppuccin theme, no Pocket, no Sync, autoscroll, DuckDuckGo, no
translation offer, no password prompts, no bookmarks toolbar, about:blank as
home and new tab. Both add-ons are normal_installed and the preferences keep
status "default", so none of it is locked away — undoing settings by hand was
the reason to leave LibreWolf.

desktop.nix carried thirteen topics over 637 lines, and the existing split
followed the NixOS option namespace rather than the topic: services.pipewire
here, its configPackages there; services.gvfs and services.udisks2 apart from
their packages; Bluetooth likewise. Nine modules now each hold one topic with
its options, packages, configs and services together. desktop.nix keeps the
compositor, the /etc deployment, portals and what belongs to no topic.

The refactor changes nothing about the built system, and that was checked
after each of the eight steps rather than assumed. The plain store path does
not serve as the criterion: moving a package to another module reorders
environment.systemPackages, which changes the system-path hash and propagates
into every file naming it. What was compared instead is the package set
through diff-closures and every differing file with store hashes normalised
away. Two steps reordered the user tmpfiles list, which is neutral only
because no two rules name the same path — checked, not presumed.
2026-09-24 15:18:33 +02:00

112 lines
4.6 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;
# 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;
};
# normal_installed rather than force_installed: both add-ons stay 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
# neither add-on 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";
};
${catppuccinThemeId} = {
installation_mode = "normal_installed";
install_url = "https://addons.mozilla.org/firefox/downloads/latest/catppuccin-mocha-lavender-git/latest.xpi";
};
};
SearchEngines.Default = "DuckDuckGo";
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.
# These four types are exactly what firefox.desktop declares.
xdg.mime.defaultApplications = {
"text/html" = "firefox.desktop";
"application/xhtml+xml" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "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
];
}