Having flatpak installed breaks xdg-open mimetype functionality?

Configuring mimetypes declaratively was one thing I was super excited to do with nixos, since its historically always been the cause of a lot of loss of sanity with linux.

However, I noticed recently that if I install Flatpak, then every single url opens in the flatpak portal/opener instead, which completely ignores all of my file associations and mime types :frowning: After investigating deeper, I noticed that in the source code for xdg-open the end of the switch will prioritise flatpak over the generic opener that uses mime types.

I assume this is the cause of the issue, but how do I fix this / why is this the default behavior? I’m running sway, so none of the DE openers trigger. Is it possible to make the flatpak opener use the mimeapps.list or make it skip that entirely?
image
image

The flatpak branch should only be called when xdg-open is executed from Flatpak app:

What do you mean by “every single URL”? From which app and how are you you opening the links? Are you just calling xdg-open https://example.com in terminal emulator? Did you install it through Nix or Flatpak?

Im simply calling xdg-open from a terminal emulator. Every single app on my system is currently installed through Nix, but xdg-open opens through the flatpak opener in all the apps anyway for some reason. Heres my Flatpak config: https://github.com/bluskript/nix-config/blob/63cfa5959c824d62ce3dae360656d4f489f5375c/hosts/common/flatpak.nix

xdgOpenUsePortal seems like the culprit… but why would it ignore my mime type associations? The portal is necessary for flatpaks apps to be able to open links outside of flatpak, so I’m tempted to keep it.