{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.local.apps.firefox;
in {
  options.local.apps.firefox = {
    enable = mkEnableOption "firefox settings";
  };

  config = mkIf cfg.enable {
    programs.firefox.enable = true;
    xdg = {
      mimeApps = {
        enable = true;
        defaultApplications = {
          "text/html" = ["firefox.desktop"];
          "text/uri-list" = ["firefox.desktop"];
          "x-scheme-handler/http" = ["firefox.desktop"];
          "x-scheme-handler/https" = ["firefox.desktop"];
          "x-scheme-handler/about" = ["firefox.desktop"];
          "x-scheme-handler/unknown" = ["firefox.desktop"];
        };
      };
    };
    home.sessionVariables.DEFAULT_BROWSER = "${lib.getExe pkgs.firefox}";
  };
}
