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


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?


  • 1
    A workaround might be to set the some of the environment variables defined by the spec.
    – olejorgenb
    Commented Sep 19, 2016 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
    Commented Sep 22, 2016 at 9:06
  • Thanks @olejorgenb. That's definitely the good direction
    – cram1010
    Commented Sep 23, 2016 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
    Commented Sep 23, 2016 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
    Commented Sep 23, 2016 at 11:06

3 Answers 3


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
    Commented Sep 23, 2016 at 11:07
  • 1
    I think this is the right way. However, I don't understand why it is so complex. export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS}" is enough for me.
    – Max
    Commented Feb 4, 2020 at 12:30
  • 2
    Your simplified command corresponds to my original answer. The command has just been made more fail-proof by an editor for the case where $XDG_DATA_DIRS does not exist. I don't know why $HOME/.share was added to the list though.
    – Zimm i48
    Commented Feb 5, 2020 at 13:46
  • 2
    Shouldn't $HOME/.share be $HOME/.local/share instead? Commented Nov 27, 2021 at 0:40
  • 1
    @GerardBosch, I think the editor indeed meant $HOME/.local/share. There is no $HOME/.share defined by freedesktop.org. Unfortunately, I can't currently edit the answer. Commented Nov 18, 2023 at 11:08

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 \;

Since the current top answer does not satisfy many systems, including my archcraft one, here is my variation: Create etc/profile.d/nix-xdg-data-dirs.sh with content:

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

PS: Sry, too little reputation for commenting, hence new answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .