{ inputs, pkgs, nixosConfig, lib, ... }:
{
  imports = [
    inputs.zen-browser.homeModules.beta
  ];
  config = lib.mkIf nixosConfig.my.desktop.enable {
    home.file."catppuccin-zen" = {
      target = ".zen/default/chrome/catppuccin-zen";
      source = (
        fetchTarball {
          url = "https://github.com/catppuccin/zen-browser/tarball/c855685442c6040c4dda9c8d3ddc7b708de1cbaa";
          sha256 = "sha256:03ky8s5h9vkw4cp3nm86b0bk5qbjmqgyqq9a95xqzard4wppn3p4";
        });
    };
    programs.zen-browser = {
      enable = true;
      nativeMessagingHosts = [pkgs.firefoxpwa];
      policies = {
        AutofillAddressEnabled = false;
        AutofillCreditCardEnabled = false;
        DisableAppUpdate = true;
        DisableFeedbackCommands = true;
        DisableFirefoxStudies = true;
        DisablePocket = true;
        DisableTelemetry = true;
        DontCheckDefaultBrowser = true;
        NoDefaultBookmarks = true;
        OfferToSaveLogins = false;
        EnableTrackingProtection = {
          Value = true;
          Locked = true;
          Cryptomining = true;
          Fingerprinting = true;
        };
      };
      profiles.default.settings = {
        "zen.view.use-single-toolbar" = false;
        "zen.urlbar.replace-newtab" = false;
        "identity.fxaccounts.autoconfig.uri" = "https://www.fxa.hibana.me";
        "general.autoScroll" = true;
        "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
      };
      profiles.default.extensions.packages = 
        with inputs.firefox-addons.packages.${pkgs.stdenv.hostPlatform.system}; [
          ublock-origin
          dearrow
          bitwarden
          istilldontcareaboutcookies
          return-youtube-dislikes
          sponsorblock
          youtube-nonstop
          youtube-high-definition
          absolute-enable-right-click
          augmented-steam
          clearurls
          darkreader
          karakeep
          newtab-adapter
          steam-database
          unpaywall
          violentmonkey
      ];
      profiles.default.userChrome = ''
        @import "catppuccin-zen/themes/Mocha/Mauve/userChrome.css";
      '';
      profiles.default.userContent = ''
        @import "catppuccin-zen/themes/Mocha/Mauve/userContent.css";
      '';
    };
    xdg.mimeApps = let
      value = let
        zen-browser = inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.beta; # or twilight
      in
        zen-browser.meta.desktopFileName;

      associations = builtins.listToAttrs (map (name: {
          inherit name value;
        }) [
          "application/x-extension-shtml"
          "application/x-extension-xhtml"
          "application/x-extension-html"
          "application/x-extension-xht"
          "application/x-extension-htm"
          "x-scheme-handler/unknown"
          "x-scheme-handler/mailto"
          "x-scheme-handler/chrome"
          "x-scheme-handler/about"
          "x-scheme-handler/https"
          "x-scheme-handler/http"
          "application/xhtml+xml"
          "application/json"
          "text/plain"
          "text/html"
        ]);
    in {
      associations.added = associations;
      defaultApplications = associations;
    };
  };
}
