{ pkgs, ... }:
{
  programs.firefox = {
    enable = true;
    profiles = {
      default = {
        id = 0;
        name = "Main Profile";
        isDefault = true;
        search = {
          force = true;
          default = "DuckDuckGo";
          order = [ "DuckDuckGo" "Google" ];
          engines = {
            "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 Options" = {
              urls = [{
                template = "https://search.nixos.org/options";
                params = [
                  {
                    name = "type";
                    value = "options";
                  }
                  {
                    name = "query";
                    value = "{searchTerms}";
                  }
                ];
              }];
              icon =
                "''${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
              definedAliases = [ "@no" ];
            };
            "NixOS Wiki" = {
              urls = [{
                template = "https://nixos.wiki/index.php?search={searchTerms}";
              }];
              iconUpdateURL = "https://nixos.wiki/favicon.png";
              updateInterval = 24 * 60 * 60 * 1000; # every day
              definedAliases = [ "@nw" ];
            };
            "HomeManager Unofficial Options" = {
              urls = [{
                template = "https://home-manager-options.extranix.com";
                params = [{
                  name = "query";
                  value = "{searchTerms}";
                }];
              }];
              icon =
                "''${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
              definedAliases = [ "@hm" ];
            };
            "Arch Wiki" = {
              urls = [{
                template =
                  "https://wiki.archlinux.org/index.php?search={searchTerms}";
              }];
              iconUpdateURL = "https://wiki.archlinux.org/favicon.ico";
              definedAliases = [ "@aw" ];
            };
            "GeoGuessr Join" = {
              urls =
                [{ template = "https://www.geoguessr.com/join/{searchTerms}"; }];
              definedAliases = [ "@ggj" ];
            };
            "Google".metaData.alias =
              "@g"; # builtin engines only support specifying one additional alias
          };
        };
        # extensions = with pkgs.nur.repos.rycee.firefox-addons; [
        #   ublock-origin
        #   bitwarden
        #   multi-account-containers
        # ];
        settings = {
          "browser.search.region" = "CA";
          "browser.search.isUS" = false;
        };
      };
    };
  };
}
