Nix desktop files

desktopnix

When I install a GUI application using nix, I see desktop files end inside ~/.nix-profile directory, e.g:

~/.nix-profile/share/applications/firefox.desktop

However, my desktop expect that files to be in /user/share/applications in order to be able to create desktop icons for them.

Is there any way to tell nix to symlink desktop files to /user/share/applications so I don't have to do it manually?

Thanks

Best Answer

Supposing that you are using a distribution other than NixOS, then yes you can expect your desktop environment to be looking for your applications in /usr/share/applications while those installed with Nix are actually in ~/.nix-profile/share/applications.

Instead of creating a symlink from /usr/share/applications you should rather tell you desktop where to look. You should be able to do so by adding the following to your ~/.profile:

export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.share:"${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"

So your desktop will be looking for applications both in /usr/share/applications and ~/.nix-profile/share/applications, with a priority given to the applications installed with Nix.

For more info, https://nixos.org/wiki/KDE#Using_KDE_outside_NixOS

Related Question