Ability to manage XDG prefapps.list

Hi, I have been using NixOS and home-manager for a few weeks now, and I’m really enjoying the way it has augmented my configuration. However, I’ve recently run into an issue with XDG application defaults. If I view the contents of ~/.local/state/nix/profile/share/applications/prefapps.list, I see a section called [Default Applications], which I could imagine being VERY useful for configuring various default applications for things such as: your web browser, text editor, terminal emulator, launcher, etc. I have not been able to find a way to affect these defaults through /etc/nixos/configuration.nix nor with home-manager.

Another note about this file is that most of the listed defaults are applications I don’t even have installed, such as gvim (default editor), calcoo (default calculator), roxterm (default terminal emulator), and pcmanfm (default file manager).

I would really like to be able to affect these defaults to, for example:

  • set Emacs as my default text editor
  • set Wezterm as my default terminal
  • set Thunar as my default file manager

Please note that I am very aware of environment variables such as EDITOR, TERM and
VISUAL. While useful (and set to my preferred values on my Nix system), these variable in absolutely no way whatsoever have any effect on the behavior of xdg-open. VISUAL and EDITOR are used by other command line applications (not xdg-open), and the TERM environment variable is not so much for setting your preferred application, as it is for telling your terminal emulator about your terminals’ capabilies.

Please note that I am also very aware of ~/.config/mimeapps.list (and it’s accompanying home-manager modules), which is a perfectly useful file in it’s own right, but only allows the user to define default applications based on mime-type alone, which is not the same as prefapps.list.

For reference, here is some of the content of the prefapps.list file.

[Default Applications]

For NixOS, use xdg.mime.defaultApplications. There’s also probably going to be an home-manager equivalent.

As I stated in the post, these have nothing to do with mime types. You can’t set a default terminal emulator with mime types, like prefapps.list does.

Its coming from xdg-launch https://github.com/bbidulock/xdg-launch/blob/7406d0d7b64dff08729c2d6e3b28fbd2a3c9fd92/data/prefapps.list

You’ll have to write the file to a location where it’ll be found and if you get it working you can submit new options.

Personally I had never heard of that file before so its usage seems rare and might not be worth adding options for because its only used by xdg-launch.

Right, I’ve never heard of this prefapps.list, do you have a link to the XDG documentation?

Anyway, there’s no mention of it in neither NixOS nor home-manager, so no option to configure it declaratively.