# Manage mime-types via home-manager. Sadly the file gets overwritten by some applications and also not all of the desktop file paths are correct
# Use from home-manager like this:
#
# xdg.mimeApps.enable = true;
# xdg.mimeApps.defaultApplications = import ./mimeapps.nix {
#   inherit pkgs;
#   inherit lib;
# };

{ lib, pkgs, ... }:
let
  package-names = with pkgs; {
    "x-scheme-handler/tg" = telegram-desktop;
    "x-scheme-handler/mailto" = thunderbird;
    "message/rfc822" = thunderbird;
    "x-scheme-handler/mid" = thunderbird;
    "x-scheme-handler/webcal" = thunderbird;
    "text/calendar" = thunderbird;
    "application/x-extension-ics" = thunderbird;
    "x-scheme-handler/webcals" = thunderbird;
    "application/zip" = mate.engrampa;
    "text/plain" = xfce.mousepad;
    "image/jpeg" = nomacs;
    "application/pdf" = evince;
    "text/html" = firefox;
    "x-scheme-handler/http" = firefox;
    "x-scheme-handler/https" = firefox;
    "x-scheme-handler/chrome" = firefox;
    "application/x-extension-htm" = firefox;
    "application/x-extension-html" = firefox;
    "application/x-extension-shtml" = firefox;
    "application/xhtml+xml" = firefox;
    "application/x-extension-xhtml" = firefox;
    "application/x-extension-xht" = firefox;
    "image/svg+xml" = inkscape;
    "image/png" = nomacs;
    "x-scheme-handler/eclipse+command" = dbeaver-bin;
    "video/mp4" = vlc;
    "audio/mpeg" = vlc;
    "inode/directory" = pcmanfm;
  };
in
lib.mapAttrs (mimeType: package: [
  "${package}/share/applications/${package.pname}.desktop"
]) package-names
