{ pkgs, ... }:
{
  home.file = {
    ".tridactylrc" = {
      text = ''
        set editorcmd kitty hx %f +%l
        set newtab about:blank
      '';
    };
  };
  programs.firefox = {
    enable = true;
    package = pkgs.firefox.override {
      nativeMessagingHosts = [
        pkgs.tridactyl-native
      ];
    };
    policies = {
      DefaultDownloadDirectory = "\${home}/Downloads";
      Extensions.Install =
        builtins.map (name: "https://addons.mozilla.org/firefox/downloads/latest/${name}")
          [
            "ublock-origin"
            "tridactyl-vim"
            "privacy-badger17"
            "gruvbox-dark-theme"
            "torproject-snowflake"
            "bitwarden-password-manager"
            "terms-of-service-didnt-read"
            "shinigami-eyes"
            "darkreader"
            "sponsorblock"
            "youtube-mrbeastify"
            "return-youtube-dislikes"
            "multi-account-containers"
            "tabby-cat-friend"
            "indie-wiki-buddy"
          ];
      Extensions.Uninstall = [
        "google@search.mozilla.org"
        "bing@search.mozilla.org"
        "amazondotcom@search.mozilla.org"
        "ebay@search.mozilla.org"
        "twitter@search.mozilla.org"
      ];
      "DisableFirefoxStudies" = true;
      "DisableTelemetry" = true;
      "DisableFeedbackCommands" = true;
      "DisablePocket" = true;
    };
    profiles.jade = {
      search = {
        force = true;
        default = "ddg";
        engines = {
          "Nix Packages" = {
            urls = [
              {
                template = "https://search.nixos.org/packages";
                params = [
                  {
                    name = "query";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "pkgs" ];
          };
          "Nix Options" = {
            urls = [
              {
                template = "https://search.nixos.org/options";
                params = [
                  {
                    name = "query";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "opts" ];
          };
          "Home manager Options" = {
            urls = [
              {
                template = "https://home-manager-options.extranix.com/";
                params = [
                  {
                    name = "query";
                    value = "{searchTerms}";
                  }
                  {
                    name = "release";
                    value = "master";
                  }
                ];
              }
            ];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "hm" ];
          };
          "NixOS Wiki" = {
            urls = [
              {
                template = "https://nixos.wiki/index.php";
                params = [
                  {
                    name = "search";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "nxwk" ];
          };
          "Noogle" = {
            urls = [
              {
                template = "https://noogle.dev/q";
                params = [
                  {
                    name = "term";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            definedAliases = [ "ngl" ];
          };
          "lib.rs" = {
            urls = [
              {
                template = "https://lib.rs/search";
                params = [
                  {
                    name = "q";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "https://lib.rs/favicon.png";
            definedAliases = [ "libs" ];
          };
          "rust docs" = {
            urls = [
              {
                template = "https://docs.rs/releases/search";
                params = [
                  {
                    name = "query";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "https://docs.rs/-/static/favicon.ico";
            definedAliases = [ "docs" ];
          };
          "rust docs direct open" = {
            urls = [
              {
                template = "https://docs.rs/{searchTerms}";
              }
            ];
            definedAliases = [
              "doc"
              "docd"
            ];
          };
          "rust std docs" = {
            urls = [
              {
                template = "https://docs.rust-lang.org/std/index.html";
                params = [
                  {
                    name = "search";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
            icon = "https://doc.rust-lang.org/favicon.ico";
            definedAliases = [ "std" ];
          };
          "MDN" = {
            urls = [
              {
                template = "https://developer.mozilla.org/search";
                params = [
                  {
                    name = "q";
                    value = "{searchTerms}";
                  }
                ];
              }
            ];
          };
          "bing".metaData.hidden = true;
          "google".metaData.hidden = true;
          "Amazon.de".metaData.hidden = true;
        };
      };
      settings = {
        "devtools.editor.keymap" = "vim";
        "devtools.toolbox.host" = "right";
        "devtools.theme" = "dark";
        "webgl.disabled" = false;
        "browser.urlbar.decodeURLsOnCopy" = true;
        "browser.urlbar.unitConversion.enabled" = true;
        "browser.urlbar.suggest.calculator" = true;
        "browser.compactmode.show" = true;
        "browser.uidensity" = 1;
        "screenshots.browser.component.enabled" = true;
        "browser.aboutConfig.showWarning" = false;
        "browser.aboutwelcome.showModal" = false;
        "browser.aboutwelcome.enabled" = false;
        "browser.preferences.moreFromMozilla" = false;
        "browser.menu.showViewImageInfo" = true;
        "browser.shopping.experience2023.active" = false;
        "browser.shopping.experience2023.survey.enabled" = false;

        "identity.fxaccounts.enabled" = true;
        "browser.tabs.firefox-view" = true;
        "browser.tabs.firefox-view-next" = true;
        "browser.newtabpage.activity-stream.showSponsored" = false;
        "browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
        "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts" = false;
        "privacy.trackingprotection.emailtracking.enabled" = true;
        "privacy.trackingprotection.enabled" = true;
        "privacy.trackingprotection.socialtracking.enabled" = true;

        "browser.ml.chat.enabled" = false;
        "browser.ml.chat.hideLocalhost" = false;
        "browser.ml.chat.prompt.prefix" = "";
        "browser.ml.chat.prompts.0" = "";
        "browser.ml.chat.prompts.1" = "";
        "browser.ml.chat.prompts.2" = "";
        "browser.ml.chat.prompts.3" = "";
        "browser.ml.chat.provider" = "";
        "browser.ml.chat.shortcuts" = false;
        "browser.ml.chat.shortcuts.custom" = false;
        "browser.ml.chat.shortcuts.longPress" = "";
        "browser.ml.chat.sidebar" = false;

        "geo.provider.network.logging.enabled" = true;
        "extensions.getAddons.showPane" = false;
        "extensions.htmlaboutaddons.recommendations.enabled" = false;
        "browser.discovery.enabled" = false;
        "browser.shopping.experience2023.enabled" = false;
        "datareporting.policy.dataSubmissionEnabled" = false;
        "datareporting.healthreport.uploadEnabled" = false;
        "toolkit.telemetry.unified" = false;
        "toolkit.telemetry.enabled" = false;
        "toolkit.telemetry.server" = "data:,";
        "toolkit.telemetry.archive.enabled" = false;
        "toolkit.telemetry.newProfilePing.enabled" = false;
        "toolkit.telemetry.shutdownPingSender.enabled" = false;
        "toolkit.telemetry.updatePing.enabled" = false;
        "toolkit.telemetry.bhrPing.enabled" = false;
        "toolkit.telemetry.firstShutdownPing.enabled" = false;
        "toolkit.telemetry.coverage.opt-out" = true;
        "toolkit.coverage.opt-out" = true;
        "toolkit.coverage.endpoint.base" = "";
        "browser.ping-centre.telemetry" = false;
        "browser.newtabpage.activity-stream.feeds.telemetry" = false;
        "browser.newtabpage.activity-stream.telemetry" = false;
        "app.shield.optoutstudies.enabled" = false;
        "app.normandy.enabled" = false;
        "app.normandy.api_url" = "";
        "dom.private-attribution.submission.enabled" = false;
        "browser.newtabpage.activity-stream.feeds.showWeather" = false;
        "browser.newtabpage.activity-stream.feeds.weatherfeed" = false;

        "browser.safebrowsing.malware.enabled" = false;
        "browser.safebrowsing.phishing.enabled" = false;
        "browser.safebrowsing.downloads.enabled" = false;
        "browser.safebrowsing.downloads.remote.enabled" = false;
        "browser.safebrowsing.downloads.remote.url" = "";
        "browser.safebrowsing.downloads.remote.block_potentially_unwanted" = false;
        "browser.safebrowsing.downloads.remote.block_uncommon" = false;
        "browser.safebrowsing.allowOverride" = false;

        "network.prefetch-next" = false;
        "network.dns.disablePrefetch" = true;
        "network.dns.disablePrefetchFromHTTPS" = true;
        "network.predictor.enabled" = false;
        "network.predictor.enable-prefetch" = false;
        "network.http.speculative-parallel-limit" = 0;
        "browser.places.speculativeConnect.enabled" = false;
        "browser.send_pings" = false;

        "browser.urlbar.pocket.featureGate" = false;
        "browser.urlbar.weather.featureGate" = false;
        "browser.urlbar.speculativeConnect.enabled" = false;
        "browser.urlbar.suggest.quicksuggest.nonsponsored" = false;
        "browser.urlbar.suggest.quicksuggest.sponsored" = false;
        "browser.search.suggest.enabled" = false;
        "browser.urlbar.suggest.searches" = false;
        "browser.urlbar.trending.featureGate" = false;

        "security.ssl.require_safe_negotiation" = true;
        "security.remote_settings.crlite_filters.enabled" = true;
        "security.pki.crlite_mode" = 2;

        "dom.security.https_only_mode" = true;
        "dom.security.https_only_mode_pbm" = true;
        "security.ssl.treat_unsafe_negotiation_as_broken" = true;
        "browser.xul.error_pages.expert_bad_cert" = true;
        "network.http.referer.XOriginTrimmingPolicy" = 2;

        "privacy.userContext.enabled" = true;
        "privacy.userContext.ui.enabled" = true;
        "privacy.userContext.newTabContainerOnLeftClick.enabled" = true;

        "dom.disable_window_move_resize" = true;

        "browser.uitour.enabled" = false;

        "browser.uitour.url" = "";
        "permissions.manager.defaultsUrl" = "";
        "webchannel.allowObject.urlWhitelist" = "";

        "network.IDN_show_punycode" = true;
        "pdfjs.disabled" = false;
        "pdfjs.enableScripting" = false;
        "browser.tabs.searchclipboardfor.middleclick" = false;
        "browser.download.useDownloadDir" = false;
        "browser.download.alwaysOpenPanel" = false;

        "browser.download.manager.addToRecentDocs" = false;

        "browser.download.always_ask_before_handling_new_types" = true;
        "privacy.resistFingerprinting" = true;
        "privacy.resistFingerprinting.pbmode" = true;
        "privacy.window.maxInnerWidth" = 1600;
        "privacy.window.maxInnerHeight" = 900;
        "privacy.resistFingerprinting.block_mozAddonManager" = true;
        "privacy.resistFingerprinting.letterboxing" = false;
        "widget.non-native-theme.enabled" = true;
        "browser.link.open_newwindow" = 3;
        "browser.link.open_newwindow.restriction" = 0;
        "signon.rememberSignons" = false;
        "dom.popup_allowed_events" = "click dblclick mousedown pointerdown";
        "browser.pagethumbnails.capturing_disabled" = true;

        "geo.enabled" = false;
        "full-screen-api.enabled" = false;
        "permissions.default.geo" = 0;
        "permissions.default.camera" = 0;
        "permissions.default.microphone" = 0;
        "permissions.default.desktop-notification" = 0;
        "permissions.default.xr" = 0;
      };
    };
  };
}
