Where are .desktop files located?

I am trying to modify my mimeapps.list using home-manager, so I am wanting to find a list of .desktop files on my system. I have seen some people say to look in /run/current-system/sw/share/applications. On my system, this directory only has:


I have also seen others mention $XDG_DATA_DIRS. I have looked at every directory defined by that variable, and none of them contain the desktop entries for the applicatoins I have installed.

I have found the following directory /nix/store/hash-home-manager-path/share/applications that seems to contain all of my .desktop files, but I cannot figure out which directory is linked to it. It seems that there isn’t any.

Isn’t there a symlink to all of my .desktop files?

1 Like

Generally if you want to put stuff in XDG_DATA_DIRS,you should just copy the dirextories in $out/share. In this case .desktop files should be copied to $out/share/applications.Remember to mkdir -p $out/share/applications beforehand

I think you misunderstood. I am not wanting to put anything into XDG_DATA_DIRS or anywhere else. I am not creating .desktop files. I am trying to find the .desktop files that were created by the applications I have installed.

1 Like

If you did ls -l, you would see where it comes from

$ ls -l /run/current-system/sw/share/applications
lrwxrwxrwx 113 root 31 Dec  1969 com.yubico.yubioath.desktop -> /nix/store/c06p6h49fkbr0ln48rqpxnczf97p4qvi-yubioath-desktop-5.0.5/share/applications/com.yubico.yubioath.desktop
lrwxrwxrwx  89 root 31 Dec  1969 cups.desktop -> /nix/store/x1b76mzqszl4xd4hf2976jf23vw6a11h-cups-2.3.3op2/share/applications/cups.desktop
lrwxrwxrwx  83 root 31 Dec  1969 i3.desktop -> /nix/store/cvcgglk16d2jkwphsqipgbv4az8h5zrr-i3-4.20.1/share/applications/i3.desktop
.r--r--r-- 299 root 31 Dec  1969 mimeinfo.cache
lrwxrwxrwx  94 root 31 Dec  1969 nixos-manual.desktop -> /nix/store/nj4280dlq1r3dr1m7mbjs1wsbn6b5ljn-nixos-help/share/applications/nixos-manual.desktop
lrwxrwxrwx 109 root 31 Dec  1969 nvidia-settings.desktop -> /nix/store/b3azij2gsqm0xr0rdnl9k15pn89pq9sq-nvidia-settings-495.46/share/applications/nvidia-settings.desktop
lrwxrwxrwx  82 root 31 Dec  1969 steam.desktop -> /nix/store/cdv18mx4kqd8m7y74h0dndnsip2bydcj-steam/share/applications/steam.desktop
lrwxrwxrwx  99 root 31 Dec  1969 virtualbox.desktop -> /nix/store/gpsj05kj9jq0v8h179kwfzxxlsfmwm2c-virtualbox-6.1.28/share/applications/virtualbox.desktop
lrwxrwxrwx  86 root 31 Dec  1969 xterm.desktop -> /nix/store/8rdy8g8b1mjwiiz5vdi3ab4f0x4dh7ja-xterm-370/share/applications/xterm.desktop

When packages are included in environment.systemPackages, a nixos module for creating the system will look for <pkg>/share/applications/*.desktop paths, and add them to this directory. Specifically: nixpkgs/menus.nix at 7b2f9d4732d36d305d515f20c5caf7fe1961df80 · NixOS/nixpkgs · GitHub


NixOS sets this for you:


Yes. Understood. But what about packages included in home.packages? Where do those .desktop files get symlinked to?

Right. But nowhere in that path are the .desktop files of packages added in home.packages. Where are those .desktop files symlinked?

Could /etc/profiles/per-user/<username>/share/applications/ be what you are looking for?


I don’t have an /etc/profiles.

I wonder why that might be. Should it exist?

Hmm. Maybe it is only created when using home-manager as a NixOS module. Do you use home-manager by itself?

I am using home-manager stand-alone, not as a module.

In that case run nix-build ... thengo look in result/share/applications

Then HMs env will be merged with the users env into ~/.nix-profile

1 Like