From 95eb2f49a66fb94fcec940d238bfb3e11325b58e Mon Sep 17 00:00:00 2001 From: Nate Anderson Date: Sun, 15 Feb 2026 21:56:24 -0700 Subject: [PATCH] update firefox module --- shared/modules/apps/firefox/firefox.nix | 257 ++++++++++++++---------- 1 file changed, 153 insertions(+), 104 deletions(-) diff --git a/shared/modules/apps/firefox/firefox.nix b/shared/modules/apps/firefox/firefox.nix index 898176a..e3675b5 100644 --- a/shared/modules/apps/firefox/firefox.nix +++ b/shared/modules/apps/firefox/firefox.nix @@ -1,123 +1,172 @@ -{lib, config, pkgs, inputs, options, ...}: +{ + lib, + config, + pkgs, + inputs, + options, + ... +}: let cfg = config.firefoxApp; # Check if stylix home-manager module is loaded by checking for the firefox target option # Only check options (not config) to avoid infinite recursion during module evaluation - hasStylixFirefox = (options ? stylix) && (options.stylix ? targets) && (options.stylix.targets ? firefox); + hasStylixFirefox = + (options ? stylix) && (options.stylix ? targets) && (options.stylix.targets ? firefox); in { - # imports = [ - # inputs.nur.hmModules.nur - # ]; + # imports = [ + # inputs.nur.hmModules.nur + # ]; - options.firefoxApp = { - enable = lib.mkEnableOption "enable firefox browser"; - }; - config = lib.mkIf cfg.enable (lib.mkMerge ([ + options.firefoxApp = { + enable = lib.mkEnableOption "enable firefox browser"; + }; + config = lib.mkIf cfg.enable ( + lib.mkMerge ( + [ # Firefox configuration { - programs.firefox = { + programs.firefox = { # Add pipewire support # package = (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {}); enable = true; profiles = { - default = { - id = 0; - name = "default"; - isDefault = true; - extensions.packages = with pkgs; [ - nur.repos.rycee.firefox-addons.darkreader - nur.repos.rycee.firefox-addons.keepassxc-browser - nur.repos.crazazy.firefox-addons.ublock-origin - nur.repos.bandithedoge.firefoxAddons.stylus - ]; - search = { - # Replace default firefox search engine config with this one - force = true; - default = "Kagi"; - engines = { - "Kagi" = { - urls = [{ - template = "https://kagi.com/search?q={searchTerms}"; - }]; - }; - "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" = { - urls = [{ - template = "https://wiki.nixos.org/w/index.php"; - params = [ - { name = "search"; value = "{searchTerms}"; } - ]; - }]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = [ "@nix" ]; - }; - "MySQL Docs" = { - urls = [{ - template = "https://dev.mysql.com/doc/search"; - params = [ - { name = "d"; value = "371"; } - { name = "p"; value = "1"; } - { name = "q"; value = "{searchTerms}"; } - ]; - }]; - definedAliases = [ "@mysql" ]; - }; - "SQLite Docs" = { - urls = [{ - template = "https://www.sqlite.org/search?s=d&q=strict"; - params = [ - { name = "s"; value = "d"; } - { name = "q"; value = "{searchTerms}"; } - ]; - }]; - definedAliases = [ "@sqlite" ]; - }; - }; - }; - settings = { - "browser.startup.blankWindow" = true; - "browser.startup.homepage" = "https://www.kagi.com"; - "browser.search.region" = "US"; - "browser.search.isUS" = true; - "distribution.searchplugins.defaultLocale" = "en-US"; - "general.useragent.locale" = "en-US"; - "extensions.activeThemeID" = "{831b8843-7251-4306-9521-e688f18b4aeb}"; - "privacy.trackingprotection.enable" = true; - "privacy.trackingprotection.emailtracking.enable" = true; - "privacy.trackingprotection.socialtracking.enable" = true; - "privacy.clearOnShutdown.cookies" = true; - "browser.safebrowsing.passwords.enabled" = false; - "browser.migrate.interactions.passwords" = false; - "pref.privacy.disable_button.view_passwords" = false; - "signon.rememberSignon" = false; - "extensions.formautofill.creditCards.enabled" = false; - "extensions.formautofill.addresses.enabled" = false; - "browser.toolbars.bookmarks.visibility" = "always"; - # For applying userContent.css - not being used - # "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - # "browser.newtabpage.pinned" = [{ - # title = "NixOS"; - # url = "https://nixos.org"; - # }]; - }; + default = { + id = 0; + name = "default"; + isDefault = true; + extensions = { + force = true; + packages = with pkgs; [ + nur.repos.rycee.firefox-addons.darkreader + nur.repos.rycee.firefox-addons.keepassxc-browser + nur.repos.crazazy.firefox-addons.ublock-origin + ]; }; + search = { + # Replace default firefox search engine config with this one + force = true; + default = "Kagi"; + engines = { + "Kagi" = { + urls = [ + { + template = "https://kagi.com/search?q={searchTerms}"; + } + ]; + }; + "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" = { + urls = [ + { + template = "https://wiki.nixos.org/w/index.php"; + params = [ + { + name = "search"; + value = "{searchTerms}"; + } + ]; + } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@nix" ]; + }; + "MySQL Docs" = { + urls = [ + { + template = "https://dev.mysql.com/doc/search"; + params = [ + { + name = "d"; + value = "371"; + } + { + name = "p"; + value = "1"; + } + { + name = "q"; + value = "{searchTerms}"; + } + ]; + } + ]; + definedAliases = [ "@mysql" ]; + }; + "SQLite Docs" = { + urls = [ + { + template = "https://www.sqlite.org/search?s=d&q=strict"; + params = [ + { + name = "s"; + value = "d"; + } + { + name = "q"; + value = "{searchTerms}"; + } + ]; + } + ]; + definedAliases = [ "@sqlite" ]; + }; + }; + }; + settings = { + "browser.startup.blankWindow" = true; + "browser.startup.homepage" = "https://www.kagi.com"; + "browser.search.region" = "US"; + "browser.search.isUS" = true; + "distribution.searchplugins.defaultLocale" = "en-US"; + "general.useragent.locale" = "en-US"; + "extensions.activeThemeID" = "{831b8843-7251-4306-9521-e688f18b4aeb}"; + "privacy.trackingprotection.enable" = true; + "privacy.trackingprotection.emailtracking.enable" = true; + "privacy.trackingprotection.socialtracking.enable" = true; + "privacy.clearOnShutdown.cookies" = true; + "browser.safebrowsing.passwords.enabled" = false; + "browser.migrate.interactions.passwords" = false; + "pref.privacy.disable_button.view_passwords" = false; + "signon.rememberSignon" = false; + "extensions.formautofill.creditCards.enabled" = false; + "extensions.formautofill.addresses.enabled" = false; + "browser.toolbars.bookmarks.visibility" = "always"; + # For applying userContent.css - not being used + # "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + # "browser.newtabpage.pinned" = [{ + # title = "NixOS"; + # url = "https://nixos.org"; + # }]; + }; + }; }; - }; - } - ] ++ lib.optional hasStylixFirefox { + }; + } + ] + ++ lib.optional hasStylixFirefox { # Stylix integration (only if stylix module is loaded) # Uses mkIf to check autoEnable at runtime, avoiding infinite recursion stylix.targets.firefox.profileNames = lib.mkIf config.stylix.autoEnable [ "default" ]; - })); + } + ) + ); }