From 92ecf9711ff726b9be11bab9c9baa1bfbea90bf6 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Mon, 12 Oct 2026 23:31:36 +0200 Subject: home: firefox: reorganize --- .../personal/programs/firefox/default.nix | 103 +---------- .../personal/programs/firefox/engines.nix | 175 ------------------ .../personal/programs/firefox/extensions.nix | 88 ++++++++++ .../personal/programs/firefox/search.nix | 195 +++++++++++++++++++++ .../personal/programs/firefox/userjs.nix | 134 +++++++------- 5 files changed, 359 insertions(+), 336 deletions(-) delete mode 100644 modules/home-manager/personal/programs/firefox/engines.nix create mode 100644 modules/home-manager/personal/programs/firefox/extensions.nix create mode 100644 modules/home-manager/personal/programs/firefox/search.nix diff --git a/modules/home-manager/personal/programs/firefox/default.nix b/modules/home-manager/personal/programs/firefox/default.nix index 0966be1..8f33e38 100644 --- a/modules/home-manager/personal/programs/firefox/default.nix +++ b/modules/home-manager/personal/programs/firefox/default.nix @@ -1,112 +1,27 @@ { config, lib, - pkgs, ... }: -with lib; -let - userjs = pkgs.callPackage ./userjs.nix { - inherit (pkgs.personal.static.userjs) arkenfox; - inherit (pkgs.lib.personal) toUserJS; - }; - engines = import ./engines.nix { inherit lib pkgs; }; - extensions = { - canvasblocker = { - id = "CanvasBlocker@kkapsner.de"; - }; - url-in-title-keepass = { - id = "{fcdb71fb-c9e5-48a3-9d04-e32713f5da88}"; - }; - clearurls = { - id = "{74145f27-f039-47ce-a470-a662b129930a}"; - }; - temporary-containers = { - id = "{c607c8df-14a7-4f28-894f-29e8722976af}"; - }; - floccus = { - id = "floccus@handmadeideas.org"; - }; - darkreader = { - id = "addon@darkreader.org"; - }; - ublock-origin = { - id = "uBlock0@raymondhill.net"; - }; - firefox-color = { - id = "FirefoxColor@mozilla.com"; - }; - }; - -in { + imports = [ + ./extensions.nix + ./search.nix + ./userjs.nix + ]; + config = lib.mkMerge [ { stylix.targets.firefox = { - colorTheme.enable = true; + colorTheme.enable = true; # overriden settings in ./extensions.nix profileNames = [ "default" ]; }; + programs.firefox = { configPath = "${config.xdg.configHome}/mozilla/firefox"; - policies.ExtensionSettings = { - "*".installation_mode = "blocked"; - } - // lib.mapAttrs' (name: value: { - name = value.id; - value = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/${name}/latest.xpi"; - installation_mode = "force_installed"; - updates_disabled = true; - }; - }) extensions; - profiles.default = { - id = 0; # isDefault = true - extensions = { - settings."FirefoxColor@mozilla.com" = { - force = true; - settings.theme.colors = - let - mkBgColor = lib.mkForce ( - with config.lib.stylix.colors; - { - r = base00-rgb-r; - g = base00-rgb-g; - b = base00-rgb-b; - } - ); - in - { - frame = mkBgColor; - sidebar_border = mkBgColor; - popup_border = mkBgColor; - tab_baground_separator = mkBgColor; - tab_line = mkBgColor; - toolbar_field_border_focus = mkBgColor; - }; - }; - }; - search = { - force = lib.mkDefault true; - engines = - with engines; - disableDefault - // { - inherit Searx; - } - // lib.optionalAttrs config.personal.identities.personal personal - // lib.optionalAttrs config.personal.identities.work work - // lib.optionalAttrs config.personal.profiles.dev dev; - default = "Searx"; - order = [ - "Searx" - "Wikipedia" - ]; - }; - extraConfig = userjs.default; - }; - + profiles.default.id = 0; # isDefault = true }; } diff --git a/modules/home-manager/personal/programs/firefox/engines.nix b/modules/home-manager/personal/programs/firefox/engines.nix deleted file mode 100644 index 87f74e5..0000000 --- a/modules/home-manager/personal/programs/firefox/engines.nix +++ /dev/null @@ -1,175 +0,0 @@ -{ - lib, - pkgs, -}: -let - everyday = 24 * 60 * 60 * 1000; - searchTerms = "{searchTerms}"; - nixosIcon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - self = { - disable = - engines: - lib.genAttrs engines (_: { - metaData.hidden = true; - }); - disableDefault = self.disable [ - "google" - "Amazon.fr" - "bing" - ]; - - nix = { - inherit (self) - "Home Manager Options" - "NixOS Options" - "NixOS Wiki" - "Nix Packages" - ; - }; - dev = self.nix // { - inherit (self) AlternativeTo Phind; - }; - personal = { inherit (self) Emojipedia; }; - work = { inherit (self) nLab; }; - all = self.dev // self.personal // self.work // { inherit (self) Searx; }; - - Emojipedia = { - urls = [ - { - template = "https://emojipedia.org/search/"; - params = [ (lib.nameValuePair "q" searchTerms) ]; - } - ]; - icon = "https://emojipedia.org/static/img/favicons/favicon-16x16.png"; - updateInterval = everyday; - definedAliases = [ - "@emojipedia" - "@emoji" - "@em" - ]; - }; - - AlternativeTo = { - urls = [ - { - template = "https://alternativeto.net/browse/search/"; - params = [ (lib.nameValuePair "q" searchTerms) ]; - } - ]; - icon = "https://alternativeto.net/static/icons/a2/favicon-16x16.png"; - updateInterval = everyday; - definedAliases = [ - "@alternativeto" - "@a2" - ]; - }; - - "Home Manager Options" = { - urls = [ - { - template = "https://search.nixos.org/options"; - params = [ - (lib.nameValuePair "channel" "unstable") - (lib.nameValuePair "source" "home_manager") - (lib.nameValuePair "query" searchTerms) - ]; - } - ]; - icon = nixosIcon; - definedAliases = [ - "@homemanager" - "@hm" - ]; - }; - - "NixOS Options" = { - urls = [ - { - template = "https://search.nixos.org/options"; - params = [ - (lib.nameValuePair "channel" "unstable") - (lib.nameValuePair "query" searchTerms) - ]; - } - ]; - icon = nixosIcon; - definedAliases = [ - "@nixos" - "@no" - ]; - }; - - "NixOS Wiki" = { - urls = [ - { - template = "https://wiki.nixos.org/w/index.php"; - params = [ (lib.nameValuePair "search" searchTerms) ]; - } - ]; - icon = nixosIcon; - definedAliases = [ - "@nixoswiki" - "@nw" - ]; - }; - - "Nix Packages" = { - urls = [ - { - template = "https://search.nixos.org/packages"; - params = [ - (lib.nameValuePair "channel" "unstable") - (lib.nameValuePair "query" searchTerms) - ]; - } - ]; - icon = nixosIcon; - definedAliases = [ - "@nixpkgs" - "@np" - ]; - }; - - nLab = { - urls = [ - { - template = "https://ncatlab.org/nlab/search"; - params = [ (lib.nameValuePair "query" searchTerms) ]; - } - ]; - icon = "https://ncatlab.org/favicon.ico"; - updateInterval = everyday; - definedAliases = [ - "@ncatlab" - "@nlab" - ]; - }; - - Searx = { - urls = [ - { - template = "https://searx.aristote.fr/search"; - params = [ (lib.nameValuePair "q" searchTerms) ]; - } - ]; - icon = "https://searx.aristote.fr/static/themes/simple/img/favicon.svg"; - updateInterval = everyday; - }; - - Phind = { - urls = [ - { - template = "https://phind.com/search"; - params = [ (lib.nameValuePair "q" searchTerms) ]; - } - ]; - icon = "https://www.phind.com/images/favicon.png"; - updateInterval = everyday; - definedAliases = [ - "@phind" - "@ph" - ]; - }; - }; -in -self diff --git a/modules/home-manager/personal/programs/firefox/extensions.nix b/modules/home-manager/personal/programs/firefox/extensions.nix new file mode 100644 index 0000000..60982b9 --- /dev/null +++ b/modules/home-manager/personal/programs/firefox/extensions.nix @@ -0,0 +1,88 @@ +{ + config, + lib, + ... +}: +let + extensions = { + canvasblocker = { + id = "CanvasBlocker@kkapsner.de"; + }; + url-in-title-keepass = { + id = "{fcdb71fb-c9e5-48a3-9d04-e32713f5da88}"; + }; + clearurls = { + id = "{74145f27-f039-47ce-a470-a662b129930a}"; + }; + temporary-containers = { + id = "{c607c8df-14a7-4f28-894f-29e8722976af}"; + }; + floccus = { + id = "floccus@handmadeideas.org"; + }; + darkreader = { + id = "addon@darkreader.org"; + }; + ublock-origin = { + id = "uBlock0@raymondhill.net"; + }; + firefox-color = { + id = "FirefoxColor@mozilla.com"; + settings.theme.colors = + let + mkBgColor = lib.mkForce ( + with config.lib.stylix.colors; + { + r = base00-rgb-r; + g = base00-rgb-g; + b = base00-rgb-b; + } + ); + in + { + frame = mkBgColor; + sidebar_border = mkBgColor; + popup_border = mkBgColor; + tab_baground_separator = mkBgColor; + tab_line = mkBgColor; + toolbar_field_border_focus = mkBgColor; + }; + }; + }; +in +{ + programs.firefox = { + policies.ExtensionSettings = { + "*".installation_mode = "blocked"; + } + // lib.mapAttrs' (name: { id, ... }: { + name = id; + value = { + install_url = "https://addons.mozilla.org/firefox/downloads/latest/${name}/latest.xpi"; + installation_mode = "force_installed"; + updates_disabled = true; + }; + }) extensions; + + profiles.default.extensions.settings = lib.mapAttrs' ( + _: + { + id, + settings ? { }, + }: + { + name = id; + value = + if settings != { } then + { + force = true; + inherit settings; + } + else + { + force = false; + }; + } + ) extensions; + }; +} diff --git a/modules/home-manager/personal/programs/firefox/search.nix b/modules/home-manager/personal/programs/firefox/search.nix new file mode 100644 index 0000000..0a4178d --- /dev/null +++ b/modules/home-manager/personal/programs/firefox/search.nix @@ -0,0 +1,195 @@ +{ + config, + lib, + pkgs, + ... +}: +let + everyday = 24 * 60 * 60 * 1000; + searchTerms = "{searchTerms}"; + nixosIcon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + engines = { + disable = + engines: + lib.genAttrs engines (_: { + metaData.hidden = true; + }); + disableDefault = engines.disable [ + "google" + "Amazon.fr" + "bing" + ]; + + nix = { + inherit (engines) + "Home Manager Options" + "NixOS Options" + "NixOS Wiki" + "Nix Packages" + ; + }; + dev = engines.nix // { + inherit (engines) AlternativeTo Phind; + }; + personal = { inherit (engines) Emojipedia; }; + work = { inherit (engines) nLab; }; + all = engines.dev // engines.personal // engines.work // { inherit (engines) Searx; }; + + Emojipedia = { + urls = [ + { + template = "https://emojipedia.org/search/"; + params = [ (lib.nameValuePair "q" searchTerms) ]; + } + ]; + icon = "https://emojipedia.org/static/img/favicons/favicon-16x16.png"; + updateInterval = everyday; + definedAliases = [ + "@emojipedia" + "@emoji" + "@em" + ]; + }; + + AlternativeTo = { + urls = [ + { + template = "https://alternativeto.net/browse/search/"; + params = [ (lib.nameValuePair "q" searchTerms) ]; + } + ]; + icon = "https://alternativeto.net/static/icons/a2/favicon-16x16.png"; + updateInterval = everyday; + definedAliases = [ + "@alternativeto" + "@a2" + ]; + }; + + "Home Manager Options" = { + urls = [ + { + template = "https://search.nixos.org/options"; + params = [ + (lib.nameValuePair "channel" "unstable") + (lib.nameValuePair "source" "home_manager") + (lib.nameValuePair "query" searchTerms) + ]; + } + ]; + icon = nixosIcon; + definedAliases = [ + "@homemanager" + "@hm" + ]; + }; + + "NixOS Options" = { + urls = [ + { + template = "https://search.nixos.org/options"; + params = [ + (lib.nameValuePair "channel" "unstable") + (lib.nameValuePair "query" searchTerms) + ]; + } + ]; + icon = nixosIcon; + definedAliases = [ + "@nixos" + "@no" + ]; + }; + + "NixOS Wiki" = { + urls = [ + { + template = "https://wiki.nixos.org/w/index.php"; + params = [ (lib.nameValuePair "search" searchTerms) ]; + } + ]; + icon = nixosIcon; + definedAliases = [ + "@nixoswiki" + "@nw" + ]; + }; + + "Nix Packages" = { + urls = [ + { + template = "https://search.nixos.org/packages"; + params = [ + (lib.nameValuePair "channel" "unstable") + (lib.nameValuePair "query" searchTerms) + ]; + } + ]; + icon = nixosIcon; + definedAliases = [ + "@nixpkgs" + "@np" + ]; + }; + + nLab = { + urls = [ + { + template = "https://ncatlab.org/nlab/search"; + params = [ (lib.nameValuePair "query" searchTerms) ]; + } + ]; + icon = "https://ncatlab.org/favicon.ico"; + updateInterval = everyday; + definedAliases = [ + "@ncatlab" + "@nlab" + ]; + }; + + Searx = { + urls = [ + { + template = "https://searx.aristote.fr/search"; + params = [ (lib.nameValuePair "q" searchTerms) ]; + } + ]; + icon = "https://searx.aristote.fr/static/themes/simple/img/favicon.svg"; + updateInterval = everyday; + }; + + Phind = { + urls = [ + { + template = "https://phind.com/search"; + params = [ (lib.nameValuePair "q" searchTerms) ]; + } + ]; + icon = "https://www.phind.com/images/favicon.png"; + updateInterval = everyday; + definedAliases = [ + "@phind" + "@ph" + ]; + }; + }; +in +{ + programs.firefox.profiles.default.search = { + force = lib.mkDefault true; + engines = + with engines; + disableDefault + // { + inherit Searx; + } + // lib.optionalAttrs config.personal.identities.personal personal + // lib.optionalAttrs config.personal.identities.work work + // lib.optionalAttrs config.personal.profiles.dev dev; + default = "Searx"; + order = [ + "Searx" + "Wikipedia" + ]; + }; +} diff --git a/modules/home-manager/personal/programs/firefox/userjs.nix b/modules/home-manager/personal/programs/firefox/userjs.nix index 4fda63f..5db8e58 100644 --- a/modules/home-manager/personal/programs/firefox/userjs.nix +++ b/modules/home-manager/personal/programs/firefox/userjs.nix @@ -1,74 +1,74 @@ { - arkenfox, - toUserJS, + pkgs, + ... }: let - self = { - arkenfox = builtins.readFile "${arkenfox}"; - default = - self.arkenfox - + toUserJS { - "signon.rememberSignons" = false; # 0901 - "security.nocertdb" = true; # 1222 - "media.peerconnection.enabled" = false; # 2001 - "media.peerconnection.ice.no_host" = true; # 2004 - "dom.allow_cut_copy" = true; # 2404 - "dom.battery.enabled" = false; # 2502 - "permissions.default.xr" = 2; # 2521 - "browser.search.separatePrivateDefault" = false; # 0830 - "browser.search.separatePrivateDefault.ui.enabled" = false; # 0830 - "privacy.clearOnShutdown_v2.historyFormDataAndDownloads" = true; # 2811 - "privacy.clearOnShutdown_v2.browsingHistoryAndDownloads" = true; # 2812 - "privacy.clearOnShutdown_v2.downloads" = true; # 2812 - "privacy.clearSiteData.historyFormDataAndDownloads" = true; # 2820 - "privacy.clearSiteData.browsingHistoryAndDownloads" = true; # 2821 - "privacy.clearHistory.historyFormDataAndDownloads" = true; # 2830 - "privacy.clearHistory.browsingHistoryAndDownloads" = true; # 2831 + arkenfox = builtins.readFile "${pkgs.personal.static.userjs.arkenfox}"; + default = + arkenfox + + pkgs.lib.personal.toUserJS { + "signon.rememberSignons" = false; # 0901 + "security.nocertdb" = true; # 1222 + "media.peerconnection.enabled" = false; # 2001 + "media.peerconnection.ice.no_host" = true; # 2004 + "dom.allow_cut_copy" = true; # 2404 + "dom.battery.enabled" = false; # 2502 + "permissions.default.xr" = 2; # 2521 + "browser.search.separatePrivateDefault" = false; # 0830 + "browser.search.separatePrivateDefault.ui.enabled" = false; # 0830 + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads" = true; # 2811 + "privacy.clearOnShutdown_v2.browsingHistoryAndDownloads" = true; # 2812 + "privacy.clearOnShutdown_v2.downloads" = true; # 2812 + "privacy.clearSiteData.historyFormDataAndDownloads" = true; # 2820 + "privacy.clearSiteData.browsingHistoryAndDownloads" = true; # 2821 + "privacy.clearHistory.historyFormDataAndDownloads" = true; # 2830 + "privacy.clearHistory.browsingHistoryAndDownloads" = true; # 2831 - # Personal - ## Warnings - "browser.tabs.warnOnClose" = false; - "browser.tabs.warnOnCloseOtherTabs" = false; - ## Updates - "app.update.auto" = false; - "browser.search.update" = false; - ## Appearance - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - ## Content behavior - "clipboard.autocopy" = false; - ## UX behavior - "browser.quitShortcut.disabled" = true; - "browser.tabs.closeWindowWithLastTab" = false; - ## UX features - "extensions.pocket.enabled" = false; - "identity.fxaccounts.enabled" = false; - }; + # Personal + ## Warnings + "browser.tabs.warnOnClose" = false; + "browser.tabs.warnOnCloseOtherTabs" = false; + ## Updates + "app.update.auto" = false; + "browser.search.update" = false; + ## Appearance + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + ## Content behavior + "clipboard.autocopy" = false; + ## UX behavior + "browser.quitShortcut.disabled" = true; + "browser.tabs.closeWindowWithLastTab" = false; + ## UX features + "extensions.pocket.enabled" = false; + "identity.fxaccounts.enabled" = false; + }; - streaming = - self.default - + toUserJS { - # Cache - "browser.cache.disk.enable" = true; - "browser.cache.offline.storage" = true; - # Privacy - "privacy.clearOnShutdown_v2.cache" = false; - "privacy.clearOnShutdown_v2.cookiesAndStorage" = false; - }; + # streaming = + # default + # + pkgs.lib.personal.toUserJS { + # # Cache + # "browser.cache.disk.enable" = true; + # "browser.cache.offline.storage" = true; + # # Privacy + # "privacy.clearOnShutdown_v2.cache" = false; + # "privacy.clearOnShutdown_v2.cookiesAndStorage" = false; + # }; - videoconferencing = - self.default - + toUserJS { - # IMPORTANT: uncheck "Prevent WebRTC from leaking local IP addresses" in uBlock Origin's settings - # NOTE: if using RFP (4501) - # some sites, e.g. Zoom, need a canvas site exception [Right Click>View Page Info>Permissions] - # Discord video does not work: it thinks you are FF78: use a separate profile or spoof the user agent - "media.peerconnection.enabled" = true; - "media.peerconnection.ice.no_host" = false; # may or may not be required - "webgl.min_capability_mode" = true; - "media.autoplay.blocking_policy" = 0; # optional (otherwise add site exceptions) - "javascript.options.wasm" = true; # optional (some platforms may require this) - "dom.webaudio.enabled" = true; - }; - }; + # videoconferencing = + # default + # + pkgs.lib.personal.toUserJS { + # # IMPORTANT: uncheck "Prevent WebRTC from leaking local IP addresses" in uBlock Origin's settings + # # NOTE: if using RFP (4501) + # # some sites, e.g. Zoom, need a canvas site exception [Right Click>View Page Info>Permissions] + # # Discord video does not work: it thinks you are FF78: use a separate profile or spoof the user agent + # "media.peerconnection.enabled" = true; + # "media.peerconnection.ice.no_host" = false; # may or may not be required + # "webgl.min_capability_mode" = true; + # "media.autoplay.blocking_policy" = 0; # optional (otherwise add site exceptions) + # "javascript.options.wasm" = true; # optional (some platforms may require this) + # "dom.webaudio.enabled" = true; + # }; in -self +{ + programs.firefox.profiles.default.extraConfig = default; +} -- cgit v1.3.1