{pkgs, ...}: let
  flatpak-install = pkgs.writeShellScriptBin "flatpak-install" ''
    flatpak install --user --bundle "$1"
    echo
    read -p "Press Enter to close..."
  '';
in {
  home.packages = [flatpak-install];

  xdg.mimeApps = {
    enable = true;
    defaultApplications = {
      "application/vnd.flatpak" = "flatpak-bundle-installer.desktop";
    };
  };

  xdg.desktopEntries.flatpak-bundle-installer = {
    name = "Flatpak Bundle Installer";
    exec = "flatpak-install %f";
    terminal = true;
    noDisplay = true;
    type = "Application";
    mimeType = ["application/vnd.flatpak"];
  };
}
