{
  inputs,
  pkgs,
  vars,
  ...
}: {
  imports = [inputs.arkenfox.hmModules.default];
  home.file.".mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json".source = "${pkgs.plasma5Packages.plasma-browser-integration}/lib/mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json";

  programs.firefox = {
    enable = true;

    arkenfox = {
      enable = true;
      version = "119.0";
    };

    profiles.Default = {
      extensions = with inputs.firefox-addons.packages."x86_64-linux"; [
        bitwarden
        ublock-origin
        darkreader
        tabliss
        consent-o-matic
        # bypass-paywalls-clean
      ];

      search.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"];
        };

        "Home Manager" = {
          urls = [
            {
              template = "https://mipmip.github.io/home-manager-option-search";
              params = [
                {
                  name = "query";
                  value = "{searchTerms}";
                }
              ];
            }
          ];

          icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
          definedAliases = ["@hm"];
        };

        "Searx" = {
          urls = [
            {
              template = "https://paulgo.io/search";
              params = [
                {
                  name = "q";
                  value = "{searchTerms}";
                }
              ];
            }
          ];

          iconUpdateURL = "https://paulgo.io/favicon.ico";
          definedAliases = ["@sx"];
        };

        "Amazon" = {
          urls = [
            {
              template = "https://www.amazon.de/s";
              params = [
                {
                  name = "k";
                  value = "{searchTerms}";
                }
              ];
            }
          ];

          iconUpdateURL = "https://amazon.de/favicon.ico";
          definedAliases = ["@a"];
        };

        "YouTube" = {
          urls = [
            {
              template = "https://efy.piped.pages.dev/results";
              params = [
                {
                  name = "search_query";
                  value = "{searchTerms}";
                }
              ];
            }
          ];

          iconUpdateURL = "https://piped.video/favicon.ico";
          definedAliases = ["yt"];
        };
      };
      search.force = true;
      search.default = "Searx";

      settings = {
        "media.hardwaremediakeys.enabled" = false;
        "dom.security.https_only_mode" = true;
        "browser.download.panel.shown" = false;
        "browser.toolbars.bookmarks.visibility" = "always";
        "signon.rememberSignons" = false;
        "browser.formfill.enable" = false;
        "signon. prefillForms" = false;
        "browser.shell.checkDefaultBrowser" = false;
        # "browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
        "browser.uiCustomization.state" = ''{"placements":{"widget-overflow-fixed-list":[],"unified-extensions-area":["addon_darkreader_org-browser-action","plasma-browser-integration_kde_org-browser-action","_506e023c-7f2b-40a3-8066-bc5deb40aebe_-browser-action","_testpilot-containers-browser-action","7esoorv3_alefvanoon_anonaddy_me-browser-action","_a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7_-browser-action","gdpr_cavi_au_dk-browser-action","firefoxcolor_mozilla_com-browser-action","firefox-translations-addon_mozilla_org-browser-action"],"nav-bar":["back-button","forward-button","stop-reload-button","urlbar-container","downloads-button","unified-extensions-button","ublock0_raymondhill_net-browser-action","_446900e4-71c2-419f-a6a7-df9c091e268b_-browser-action"],"toolbar-menubar":["menubar-items"],"TabsToolbar":["tabbrowser-tabs","new-tab-button","alltabs-button"],"PersonalToolbar":["personal-bookmarks"]},"seen":["save-to-pocket-button","developer-button","_446900e4-71c2-419f-a6a7-df9c091e268b_-browser-action","addon_darkreader_org-browser-action","ublock0_raymondhill_net-browser-action","plasma-browser-integration_kde_org-browser-action","_506e023c-7f2b-40a3-8066-bc5deb40aebe_-browser-action","_testpilot-containers-browser-action","7esoorv3_alefvanoon_anonaddy_me-browser-action","_a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7_-browser-action","gdpr_cavi_au_dk-browser-action","firefoxcolor_mozilla_com-browser-action","firefox-translations-addon_mozilla_org-browser-action"],"dirtyAreaCache":["nav-bar","PersonalToolbar","toolbar-menubar","TabsToolbar","unified-extensions-area"],"currentVersion":20,"newElementCount":4}'';
      };
      arkenfox = {
        enable = true;
        "0000".enable = true;
        "0100" = {
          enable = true;
          # Allow setting homepage
          "0102"."browser.startup.page".value = 1;
        };
        "0200" = {
          enable = true;
        };
        "0300".enable = true;
        # We keep safebrowsing
        "0400".enable = false;
        "0600" = {
          enable = true;
          "0610"."browser.send_pings".enable = true;
        };
        "0700" = {
          enable = true;
          # Disable DNS over HTTPS
          "0710"."network.trr.mode".value = 5;
        };
        # "0800" = {
        #   enable = true;
        #   # Keep using url bar as search bar
        #   "0801"."keyword.enabled".value = true;
        # };
        "0900".enable = true;
        "1000" = {
          enable = true;
          # Enable disk cache for performance reasons
          "1001"."browser.cache.disk.enable".enable = true;
          "1001"."browser.cache.disk.enable".value = true;
        };
        "1200".enable = true;
        # I don't use container tabs
        "1700".enable = false;
        "2600" = {
          enable = true;
          # useDownloadDir
          "2651".enable = false;
          # always_ask_before_handling_new_types
          "2654".enable = false;
        };
        "2700".enable = true;
        "2800" = {
          "2812".enable = true;
        };
        "5000" = {
          "5008".enable = true;
        };
      };
    };
  };

  xdg.mimeApps.defaultApplications = {
    "text/html" = ["firefox.desktop"];
    "text/xml" = ["firefox.desktop"];
    "x-scheme-handler/http" = ["firefox.desktop"];
    "x-scheme-handler/https" = ["firefox.desktop"];
  };
}