3

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

  • 1
    A workaround might be to set the some of the environment variables defined by the spec. – olejorgenb Sep 19 '16 at 15:56
  • 1
    You tagged your question with [nixos] but do you actually use NixOS or just the Nix package manager on another distribution? And what is your desktop environment? – Zimm i48 Sep 22 '16 at 9:06
  • Thanks @olejorgenb. That's definitely the good direction – cram1010 Sep 23 '16 at 11:01
  • Hey @Zimmi48 No, I'm not in NixOs, but I thought the question is anyway related and people knowing about NixOs could bring some light. I'm using Nix in Qubes OS with Xfce, so my question was indeed simplified because maybe I will need to adapt Qubes script which reads from within the VM with Nix installed. But knowing the general behavior should be enough, and then if something in Qubes is not standardized I should report there. – cram1010 Sep 23 '16 at 11:05
  • In that case, the nixos tag is really not necessary because people following it are most likely to follow the nix tag as well. – Zimm i48 Sep 23 '16 at 11:06
8
+50

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

  • I think that this is the right answer. I will not need to check how all of this works within QubesOS. – cram1010 Sep 23 '16 at 11:07
0

After modifying $XDG_DATA_DIRS in .profile, I could not log in with Ubuntu Gnome 16.10.

Instead, I solved it with symlinks. The command below finds all links in .nix-profile/share/applications and links them into .local/share/applications. Replace teodorlu with your username.

find ~/nix-profile/share/applications -type l -exec ln -s /home/teodorlu/{} ~/.local/share/applications \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.