aboutsummaryrefslogtreecommitdiff
path: root/modules/users/browsers
diff options
context:
space:
mode:
authorLeander Scherer <leander@schererleander.de>2026-01-08 02:48:11 +0100
committerLeander Scherer <leander@schererleander.de>2026-01-08 19:08:12 +0100
commit6174f3650cf42aaf008012e828d5a1f8e2ce037f (patch)
tree9bbbd99680cd5adb56596a14734d4896bc6af733 /modules/users/browsers
parentc582c4d0675aada46fa196b7af1941ed753d055f (diff)
refactor(modules): separate nixos/home-manager modules, use standard option conventions
Diffstat (limited to 'modules/users/browsers')
-rw-r--r--modules/users/browsers/default.nix6
-rw-r--r--modules/users/browsers/firefox/default.nix276
2 files changed, 282 insertions, 0 deletions
diff --git a/modules/users/browsers/default.nix b/modules/users/browsers/default.nix
new file mode 100644
index 0000000..70a8be5
--- /dev/null
+++ b/modules/users/browsers/default.nix
@@ -0,0 +1,6 @@
+{ ... }:
+{
+ imports = [
+ ./firefox
+ ];
+}
diff --git a/modules/users/browsers/firefox/default.nix b/modules/users/browsers/firefox/default.nix
new file mode 100644
index 0000000..b5212a2
--- /dev/null
+++ b/modules/users/browsers/firefox/default.nix
@@ -0,0 +1,276 @@
+{
+ pkgs,
+ inputs,
+ config,
+ lib,
+ ...
+}:
+let
+
+ cfg = config.nx.browsers.firefox;
+ inherit (lib)
+ mkOption
+ types
+ mkIf
+ optionalString
+ optionalAttrs
+ ;
+in
+{
+
+ options.nx.browsers.firefox = {
+ enable = mkOption {
+ description = "mozilla firefox";
+ type = types.bool;
+ default = false;
+ };
+ blockGoogle = mkOption {
+ description = "blocks google banner and other";
+ type = types.bool;
+ default = true;
+ };
+ transparent = mkOption {
+ description = "make firefox transparent";
+ type = types.bool;
+ default = false;
+ };
+ cleanHome = mkOption {
+ description = "clean up firefox home";
+ type = types.bool;
+ default = true;
+ };
+ hideRecommendations = mkOption {
+ description = "hide firefox recommendations";
+ type = types.bool;
+ default = true;
+ };
+ disablePasswordManager = mkOption {
+ description = "disable built-in browser password manager";
+ type = types.bool;
+ default = true;
+ };
+ };
+
+ config = mkIf cfg.enable {
+ programs.firefox = {
+ enable = true;
+ profiles.default = {
+ extensions = {
+ packages = with inputs.firefox-addons.packages.${pkgs.system}; [
+ ublock-origin
+ istilldontcareaboutcookies
+ sponsorblock
+ decentraleyes
+ vimium-c
+ ];
+
+ force = true;
+
+ settings."uBlock0@raymondhill.net".settings = {
+ UserMessaging = {
+ uiTheme = "dark";
+ uiAccentCustom = true;
+ uiAccentCustom0 = "#2C2C2C";
+ cloudStorageEnabled = false;
+ contextMenuEnabled = false;
+ };
+ # Block annoying login with google banner
+ userFilters = optionalString cfg.blockGoogle ''
+ ||accounts.google.com/gsi/*
+ '';
+ };
+ };
+
+ search = {
+ default = "DuckDuckGo";
+ engines = {
+ nix-packages = {
+ name = "Nix Packages";
+ urls = [
+ {
+ template = "https://search.nixos.org/packages";
+ params = [
+ {
+ name = "type";
+ value = "packages";
+ }
+ {
+ name = "query";
+ value = "{searchTerms}";
+ }
+ ];
+ }
+ ];
+
+ icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
+ definedAliases = [ "@np" ];
+ };
+
+ nixos-wiki = {
+ name = "NixOS Wiki";
+ urls = [ { template = "https://wiki.nixos.org/w/index.php?search={searchTerms}"; } ];
+ iconMapObj."16" = "https://wiki.nixos.org/favicon.ico";
+ definedAliases = [ "@nw" ];
+ };
+
+ bing.metaData.hidden = true;
+ google.metaData.alias = "@g";
+ };
+ force = true;
+ };
+
+ userChrome = optionalString cfg.transparent ''
+ /* Hide Back, Forward, Reload, Stop, All Tabs, Firefox View buttons */
+ #back-button,
+ #forward-button,
+ #reload-button,
+ #stop-button,
+ #alltabs-button,
+ #firefox-view-button {
+ display: none !important;
+ }
+
+ .titlebar-buttonbox-container {
+ display: none;
+ }
+
+ #tabbrowser-tabs {
+ border-inline: none !important;
+ }
+
+ /* Transparent background tabs (above url bar) */
+ #navigator-toolbox {
+ -moz-appearance: -moz-vibrant-titlebar !important;
+ background: rgba(0, 0, 0, 0.8) !important;
+ }
+
+ /* Transparent background (behind url bar) */
+ #nav-bar {
+ background: none !important;
+ box-shadow: none !important;
+ border-top: 0px !important;
+ }
+
+ .tab-background[selected="true"] {
+ background-color: #393e43 !important;
+ background-image: none !important;
+ }
+
+ .tab-background {
+ background-color: var(--background) !important;
+ color: var(--foreground) !important;
+ box-shadow: none !important;;
+ }
+
+ .tab-background[selected] {
+ background-color: rgba(0, 0, 0, 0.30) !important;
+ color: var(--foreground) !important;
+ box-shadow: none !important;
+ }
+
+ /* Needed for transparency in general */
+ :root {
+ --tabpanel-background-color: transparent !important;
+ --chrome-content-separator-color: transparent !important;
+ --toolbar-bgcolor: rgba(0, 0, 0, 0.9) !important;
+ --newtab-background-color: rgba(0, 0, 0, 0.9) !important;
+ --newtab-background-color-secondary: transparent !important;
+ --toolbar-field-background-color: rgba(120, 120, 120, 0.10) !important;
+ }
+ '';
+ userContent = optionalString cfg.transparent ''
+ @-moz-document url-prefix("about:"), url("about:home") {
+ /* Transparent about:settings about:config about:policies */
+ :root {
+ background: rgba(0, 0, 0, 0.0) !important;
+ }
+ }
+
+ /* Transparent about:home */
+ * {
+ --newtab-background-color: transparent !important;
+ --newtab-background-color-secondary: transparent !important;
+ }
+
+ /* Transparent elements in about:* */
+ * {
+ --in-content-page-background: transparent !important;
+ --background-color-box: rgba(0, 0, 0, 0.5) !important;
+ }
+ '';
+ };
+
+ policies = {
+ DisableTelemetry = true;
+ DisableFirefoxStudies = true;
+ PasswordManagerEnabled = !cfg.disablePasswordManager;
+ OfferToSaveLogins = !cfg.disablePasswordManager;
+ DisplayBookmarksToolbar = "never";
+ NoDefaultBookmarks = true;
+
+ Homepage = optionalAttrs cfg.cleanHome {
+ URL = "about:blank";
+ Locked = true;
+ StartPage = "homepage";
+ };
+
+ NewTabPage = !cfg.cleanHome;
+
+ PictureInPicture = {
+ Enabled = false;
+ };
+
+ EnableTrackingProtection = {
+ Value = true;
+ Locked = true;
+ Cryptomining = true;
+ Fingerprinting = true;
+ };
+
+ EncryptedMediaExtensions = {
+ Enabled = true;
+ Locked = true;
+ };
+
+ FirefoxHome = {
+ Search = true;
+ TopSites = true;
+ SponsoredTopSites = !cfg.cleanHome;
+ Highlights = true;
+ Pocket = !cfg.cleanHome;
+ SponsoredPocket = !cfg.cleanHome;
+ Locked = true;
+ };
+
+ UserMessaging = {
+ ExtensionRecommendations = !cfg.hideRecommendations;
+ FeatureRecommendations = !cfg.hideRecommendations;
+ Locked = true;
+ MoreFromMozilla = !cfg.hideRecommendations;
+ SkipOnboarding = true;
+ UrlbarInterventions = !cfg.hideRecommendations;
+ };
+
+ Preferences = {
+ # Disable fullscreen notification
+ "full-screen-api.warning.timeout" = "0";
+
+ # Disable annoying translation popup
+ "browser.translations.automaticallyPopup" = false;
+
+ # Enable all extensions automatically
+ "extensions.autoDisableScopes" = 0;
+
+ # Hide ctr-tab tab preview menu
+ "browser.ctrlTab.sortByRecentlyUsed" = false;
+ }
+ // optionalAttrs cfg.transparent {
+ # transparency
+ "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
+ "browser.tabs.allow_transparent_browser" = true;
+ "gfx.webrender.all" = true;
+ };
+ };
+ };
+ };
+}