Home-manager and the mimeapps.list file on Plasma/KDE desktops

Hi all,

I found that home-manager allows me to configure the mimeapps.list file declaritively:

  xdg.mimeApps.enable = true;
  xdg.mimeApps.associations.added = {                                                                                                           

However it looks like the link created by home-manager gets overwritten by my desktop environment (KDE Plasma). This results in warnings due to a file being present that cannot be overwritten. This happen on both NixOS and non-NixOS machines.

Did anyone else experience this?
Is this a problem only happening with Plasma/KDE?
Any ideas on how to solve this? Or should I just not use this feature?

Thanks in advance!

Is your problem that the KDE apps complains when overwriting the link from home-manager or is it home-manager complaining when you ask it to replace the text file generated by KDE with a link to the nix store?

There is a NixOS option xdg.mime.defaultApplications. It writes to /etc/xdg/mimeapps.list instead of ~/.config/mimeapps.list. Maybe that can help your case as this should serve as a default if no setting is given in the user specific file but your KDE app can freely edit that text file in your home dir.

Thanks for the reply. The problem is that home-manager complains, as $SOMEONE removes the link and replaces it with a package. I guess some KDE/Plasma internal thing is doing that.

And then the next time I run home-manager switch it complains.

The NixOS option is nice to know, but only solves this on NixOS, not on other systems.

I don’t know what service is overwriting them, but in order to find out, you might look at the date the files were created after performing various operations relating to mime apps separated by time intervals. This way, you could single out the operation that performed it and perhaps be able to disable it (or not do it, if it is a user interaction).

Alternatively, you could create a home-manager group and give permissions to modify those files only to that group, consisting of home-manager only. I’m not sure if this is possible, but it’s an idea.

I was hoping that someone already ran into that and either it is a known issue with KDE/Plasma, HomeManager, .etc. or there is a simple solution that I missed. Or an error that I made…

I wouldn’t say it is an issue with either Home Manager or KDE, just an incompatibility between them. They are both likely functioning as intended.

I experienced something similar on GNOME, and my solution is simply to not touch the setting that I know will overwrite the file. Not great, but that’s all I have at the moment. Hopefully someone else has experience with it.