{ pkgs, host, ... }:
let
  vars = import ../../hosts/${host}/variables.nix;
  browserDesktop = {
    "firefox" = "firefox.desktop";
    "brave" = "brave-browser.desktop";
    "google-chrome" = "google-chrome.desktop";
    "google-chrome-stable" = "google-chrome.desktop";
    "chromium" = "chromium-browser.desktop";
    "zen" = "zen.desktop";
    "floorp" = "floorp.desktop";
    "librewolf" = "librewolf.desktop";
    "vivaldi" = "vivaldi-stable.desktop";
  };
  defaultBrowser = browserDesktop.${vars.browser} or "${vars.browser}.desktop";
in
{
  xdg = {
    enable = true;
    mime.enable = true;
    mimeApps = {
      enable = true;
      defaultApplications = {
        "text/html" = defaultBrowser;
        "x-scheme-handler/http" = defaultBrowser;
        "x-scheme-handler/https" = defaultBrowser;
        "x-scheme-handler/about" = defaultBrowser;
        "x-scheme-handler/unknown" = defaultBrowser;
      };
    };
    portal = {
      enable = true;
      extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
      config.common.default = "*";
    };
  };
}
