Dolphin does not have MIME associations

Hello everyone.

I am on NixOS unstable with a flake-based setup. I am using Hyprland and do not have the plasma desktop installed.

The way I have dolphin currently installed is:

with pkgs; [
    kdePackages.dolphin
    kdePackages.kio
    kdePackages.kdf
    kdePackages.kio-fuse
    kdePackages.kio-extras
    kdePackages.kio-admin
    kdePackages.qtwayland
    kdePackages.plasma-integration
    kdePackages.kdegraphics-thumbnailers
    kdePackages.breeze-icons
    kdePackages.qtsvg #https://www.reddit.com/r/hyprland/comments/18ecoo3/dolphin_doesnt_work_properly_in_nixos_hyprland/
    kdePackages.kservice
    shared-mime-info
];

I have also tried installing via home-manager.

I also have in my configuration.nix:

  xdg.menus.enable = true;
  xdg.mime.enable = true;

The issue I am facing is that dolphin does seem to know about neither which applications are installed on the system nor with which MIME types they are associated with.

Arch Linux had the same issue a couple of months ago: arch forum

I have also come across:
link0 link1 link2

I have tried setting XDG_MENU_PREFIX=plasma- to no avail.

When opening dolphin or running kbuildsycoca6 after rm ĀØ/.cache/ksycoca* the error message
"applications.menu" not found in QList("/etc/profiles/per-user/n/etc/xdg/menus", "/run/current-system/sw/etc/xdg/menus") is displayed.

On another machine that is using the plasma desktop, the ... /sw/etc/xdg/menus directory contains a file called plasma-applications.menu. Here dolphin behaves as expected. On my install the directory only contains another empty directory applications-merged.

I tried to find out where the plasma-applications.menu file is generated, but a github search in the nixpkgs repo only yielded three results, all of them did not seem related. search

There is also a mimeapps.list at ~/.config/mimeapps.list which contains mimetype associations. Selecting Remember application association for all files of type […] and manually typing the name of the binary in the dropdown field adds an association to the file, though dolphin does not seem to notice.

This leads me to believe that there is an issue with the generated menus.
There was an issue before with broken menus Apps installed via Home Manager are not visible within GNOME
also issue, but in the github issue they were able to run kbuildsycoca.

I found out I had to install kdePackages.plasma-workspace to get the plasma-applications.menu file to appear. After clearing the cache, the file associations started working.

This solution is less than ideal, because I don’t particularly fancy installing half of KDE to just use their file manager.

It also forces me to stylix.targets.kde.enable = false, disabling all qt theming.
This is needed because stylix throws

An error occurred while attempting to set the Plasma wallpaper:
The name org.kde.plasmashell was not provided by any .service files

Hi there, I’m having a similar issue. Have you discovered any way to get stylix working with kde without disabling all qt themeing?

Edit: For others interested, see the following issues:

I actually did, though the solution I came up with is decidedly suboptimal.

I added

 # This fixes the unpopulated MIME menus
  environment.etc."/xdg/menus/plasma-applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";

to my config. This works, but pulls all of plasma into the system closure.

3 Likes

Sadly none of these seems to resolve the issue for me. Going crazy fighting XDG and KDE dolphin. Everything I do I seem to get further removed from a solution.

1 Like

Have you figured something out?

I had this same problem: flake-based setup + Hyprland + no plasma desktop + dolphin + empty applications list + ā€œapplications.menuā€ not found error when kbuildsycoca6.
But I installed them using Home Manager.

What I found out is that kbuildsycoca5 that comes with libsForQt5.service successfully runs, and dolphin could see my applications. And of course, the applications.menu was there at ~/.local/state/nix/profiles/profile/etc/xdg/menus/applications.menu. So I copied it, kept it in my config folder, and added

xdg.configFile."menus/applications.menu".text = builtins.readFile ./applications.menu;

and swapped back libsForQt5.kservice with kdePackages.kservice.

And voila, everything works as expected!!

I also have this problem now when trying to add dolphin to my xmonad setup I use on laptop.

I install all of these packages as system packages in NixOS.

It seems to me that part of the fix is:

  # Fix unpopulated MIME menus in dolphin
  environment.etc."/xdg/menus/applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";

note that I fixed the path compare to what was said somewhere above.

The file that gets generated in /etc/xdg/menus/application.menu looks like:

 <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
  "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">

<Menu>
	<Name>Applications</Name>
	<Directory>kde-main.directory</Directory>
	<!-- Search the default locations -->
	<DefaultAppDirs/>
	<DefaultDirectoryDirs/>
	<DefaultLayout>
		<Merge type="menus"/>
		<Merge type="files"/>
		<Separator/>
		<Menuname>More</Menuname>
	</DefaultLayout>
	<Layout>
		<Merge type="menus"/>
		<Menuname>Applications</Menuname>
		<Merge type="files"/>
	</Layout>

	<Menu>
		<Name>Applications</Name>
		<Directory>kf5-unknown.directory</Directory>
		<OnlyUnallocated/>
		<Include>
			<Not>
				<!-- Don't list non-KDE core applications -->
				<And>
					<Category>Core</Category>
					<Not><Category>KDE</Category></Not>
				</And>
				<!-- Don't list SUSE's YaST in here -->
				<Category>X-SuSE-YaST</Category>
				<Category>X-KDE-settings-hardware</Category>
				<Category>X-KDE-settings-accessibility</Category>
				<Category>X-KDE-settings-components</Category>
				<Category>X-KDE-settings-desktop</Category>
				<Category>X-KDE-settings-looknfeel</Category>
				<Category>X-KDE-settings-network</Category>
				<Category>X-KDE-settings-webbrowsing</Category>
				<Category>X-KDE-settings-peripherals</Category>
				<Category>X-KDE-settings-hardware</Category>
				<Category>X-KDE-settings-power</Category>
				<Category>X-KDE-settings-security</Category>
				<Category>X-KDE-settings-sound</Category>
				<Category>X-KDE-settings-system</Category>
				<Category>X-KDE-information</Category>
				<Filename>kde-kcm_knetworkconfmodule_ss.desktop</Filename>
				<Filename>kde-medianotifications.desktop</Filename>
				<Filename>kde-audioencoding.desktop</Filename>
			</Not>
		</Include>
	</Menu>
	<Menu>
		<Name>Development</Name>
		<Directory>kf5-development.directory</Directory>
		<Menu>
			<Name>Translation</Name>
			<Directory>kf5-development-translation.directory</Directory>
			<Include>
				<And>
					<Category>Development</Category>
					<Category>Translation</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Web Development</Name>
			<Directory>kf5-development-webdevelopment.directory</Directory>
			<Include>
				<And>
					<Category>Development</Category>
					<Category>WebDevelopment</Category>
				</And>
			</Include>
		</Menu>
                <Include>
					<And>
                        <Category>Development</Category>
                        <Not><Category>Translation</Category></Not>
                        <Not><Category>WebDevelopment</Category></Not>
					</And>
                </Include>
        </Menu>
	<Menu>
		<Name>Science</Name>
		<Directory>kf5-science.directory</Directory>
		<Include>
			<And><!-- Include /any/ Science app which is not an Education app -->
				<Or>
					<Category>Astronomy</Category>
					<Category>Biology</Category>
					<Category>Chemistry</Category>
					<Category>Geology</Category>
					<Category>MedicalSoftware</Category>
					<Category>Physics</Category>
					<Category>Math</Category>
					<Category>Science</Category>
				</Or>
				<Not><Category>Education</Category></Not>
			</And>
		</Include>
	</Menu>
	<Menu>
		<Name>Education</Name>
		<Directory>kf5-education.directory</Directory>
		<Menu>
			<Name>Languages</Name>
			<Directory>kf5-edu-languages.directory</Directory>
			<Include>
				<And>
					<Category>Education</Category>
					<Category>Languages</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Mathematics</Name>
			<Directory>kf5-edu-mathematics.directory</Directory>
			<Include>
				<And>
					<Category>Education</Category>
					<Category>Math</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Miscellaneous</Name>
			<Directory>kf5-edu-miscellaneous.directory</Directory>
			<Include>
				<And>
					<Category>Education</Category>
					<Not>
						<Category>Languages</Category>
						<Category>Math</Category>
						<Category>Science</Category>
						<Category>Teaching</Category>
					</Not>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Science</Name>
			<Directory>kf5-edu-science.directory</Directory>
			<Include>
				<And>
					<Category>Education</Category>
					<Category>Science</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Tools</Name>
			<Directory>kf5-edu-tools.directory</Directory>
			<Include>
				<And>
					<Category>Education</Category>
					<Category>Teaching</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Menu>
		<Name>Games</Name>
		<Directory>kf5-games.directory</Directory>
		<Menu>
			<Name>Arcade</Name>
			<Directory>kf5-games-arcade.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>ArcadeGame</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Board</Name>
			<Directory>kf5-games-board.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>BoardGame</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Card</Name>
			<Directory>kf5-games-card.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>CardGame</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Kidsgames</Name>
			<Directory>kf5-games-kids.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>KidsGame</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>TacticStrategy</Name>
			<Directory>kf5-games-strategy.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>StrategyGame</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>Logic</Name>
			<Directory>kf5-games-logic.directory</Directory>
			<Include>
				<And>
					<Category>Game</Category>
					<Category>LogicGame</Category>
				</And>
			</Include>
		</Menu>
		<Include>
			<And>
				<Category>Game</Category>
				<Not>
					<Category>ArcadeGame</Category>
					<Category>BoardGame</Category>
					<Category>CardGame</Category>
					<Category>KidsGame</Category>
					<Category>StrategyGame</Category>
					<Category>LogicGame</Category>
				</Not>
			</And>
		</Include>
	</Menu>
	<Menu>
		<Name>Graphics</Name>
		<Directory>kf5-graphics.directory</Directory>
		<Include>
			<And>
				<Category>Graphics</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
		</Include>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>Graphics</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Menu>
		<Name>Internet</Name>
		<Directory>kf5-internet.directory</Directory>
		<Include>
			<And>
				<Category>Network</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
		</Include>
		<Menu>
			<Name>Terminal</Name>
			<Directory>kf5-internet-terminal.directory</Directory>
		</Menu>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>Network</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Menu>
		<Name>Multimedia</Name>
		<Directory>kf5-multimedia.directory</Directory>
		<Include>
			<And>
				<Category>AudioVideo</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
		</Include>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>AudioVideo</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Menu>
		<Name>Office</Name>
		<Directory>kf5-office.directory</Directory>
		<Layout>
			<Merge type="menus"/>
			<Filename>kde-koshell.desktop</Filename>
			<Filename>kde-Kontact.desktop</Filename>
			<Separator/>
			<Filename>kde-kword.desktop</Filename>
			<Filename>kde-kspread.desktop</Filename>
			<Filename>kde-kpresenter.desktop</Filename>
			<Merge type="files"/>
			<Separator/>
			<Menuname>More</Menuname>
		</Layout>
		<Include>
			<And>
				<Category>Office</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
		</Include>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>Office</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Menu>
		<Name>Settingsmenu</Name>
		<Directory>kf5-settingsmenu.directory</Directory>
		<Include>
			<Category>Settings</Category>
		</Include>
	</Menu>
	<Menu>
		<Name>System</Name>
		<Directory>kf5-system.directory</Directory>
		<Include>
			<And>
				<Category>System</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
		</Include>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>System</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
		<Menu>
			<Name>ScreenSavers</Name>
			<Directory>kf5-system-screensavers.directory</Directory>
		</Menu>
		<Menu>
			<Name>Terminal</Name>
			<Directory>kf5-system-terminal.directory</Directory>
		</Menu>
	</Menu>
	<Menu>
		<Name>Utilities</Name>
		<Directory>kf5-utilities.directory</Directory>
		<Include>
			<And>
				<Category>Utility</Category>
				<Not><Category>X-KDE-More</Category></Not>
			</And>
			<Category>TextEditor</Category>
			<Category>Accessibility</Category>
			<Category>X-KDE-Utilities-Desktop</Category>
			<Category>X-KDE-Utilities-File</Category>
			<Category>X-KDE-Utilities-Peripherals</Category>
			<Category>X-KDE-Utilities-PIM</Category>
		</Include>
		<Menu>
			<Name>XUtilities</Name>
			<Directory>kf5-utilities-xutils.directory</Directory>
		</Menu>
		<Menu>
			<Name>More</Name>
			<Directory>kf5-more.directory</Directory>
			<Include>
				<And>
					<Category>Utility</Category>
					<Category>X-KDE-More</Category>
				</And>
			</Include>
		</Menu>
	</Menu>
	<Include>
		<And>
			<Category>KDE</Category>
			<Category>Core</Category>
		</And>
	</Include>
	<DefaultMergeDirs/>
	<MergeFile>applications-kmenuedit.menu</MergeFile>
</Menu>

But this on its own doesn’t fix the list of applications i dolphin. I think it’s because All the categories are empty? I’m not sure how this XML file should look like.

However if I run:

kbuildsycoca6 --menutest

my applications are correctly detected. So I wonder how can I generate the correct XML or somehow piece this together with dolphin.

Now I actually realized that this works as expected when I start dolphin from shell. It doesn’t work when I start it using rofi as a luncher. So likely it will be related to env.

I created an overlay for dolphin to use the kservice from qt5 that still has the applications.menu. This way it can create the necessary files to make ā€˜open with’ work without having to install the complete KDE suite.

2 Likes
-            --set XDG_CONFIG_DIRS "${prev.libsForQt5.kservice}/etc/xdg:$XDG_CONFIG_DIRS" \
-            --run "${kprev.kservice}/bin/kbuildsycoca6 --noincremental ${prev.libsForQt5.kservice}/etc/xdg/menus/applications.menu"
+            --set XDG_CONFIG_DIRS "${kprev.plasma-workspace}/etc/xdg:$XDG_CONFIG_DIRS" \
+            --run "${kprev.kservice}/bin/kbuildsycoca6 --noincremental ${kprev.plasma-workspace}/etc/xdg/menus/plasma-applications.menu"

libsForQt5 is for Qt5-based KDE packages, kdePackages is for Qt6-based KDE packages.

You can use nix-locate (from nix-index) to find packages containing /etc/xdg/menus/applications.menu:

āÆ nix-locate applications.menu               
kdePackages.plasma-workspace.out                  9,904 r /nix/store/7yjy3g030g1g8q1xc4q163b500jhgnzi-plasma-workspace-6.3.3/etc/xdg/menus/plasma-applications.menu
mate.mate-menus.out                               4,187 r /nix/store/79n886x468y4hrqx5bv2ip4ps72nlqsc-mate-menus-1.28.0/etc/xdg/menus/mate-applications.menu
lxde.lxmenu-data.out                              3,984 r /nix/store/aaxbjzfb4nny937vc49sgmq20pwinkjm-lxmenu-data-0.1.5/etc/xdg/menus/lxde-applications.menu
lxqt.lxqt-menu-data.out                           5,526 r /nix/store/ss713p71m1njj86640nwgnx415fv2j5f-lxqt-menu-data-2.1.0/etc/xdg/menus/lxqt-applications.menu
libsForQt5.kservice.bin                           9,979 r /nix/store/xbgvjh686g0z3zj3hppk9mrlml23a19m-kservice-5.116.0-bin/etc/xdg/menus/applications.menu
gnome-flashback.out                               5,712 r /nix/store/dpayxs37gl8s4b6mf8imkgi8vf0mchkm-gnome-flashback-3.54.0/etc/xdg/menus/gnome-flashback-applications.menu
gnome-menus.out                                   7,579 r /nix/store/nndy2q6j2s37qm9pd2yf1yafpfzzb4kn-gnome-menus-3.36.0/etc/xdg/menus/gnome-applications.menu
xfce.garcon.out                                   4,494 r /nix/store/9498na767xlj301v5vjsp0iilxjf1vlj-garcon-4.20.0/etc/xdg/menus/xfce-applications.menu
enlightenment.enlightenment.out                   5,622 r /nix/store/74hhvdgrnkgpv21wklm10dqkzckv2vl5-enlightenment-0.27.1/etc/xdg/menus/e-applications.menu
(cura-appimage.out)                               9,979 r /nix/store/kz6m3knhccbkqpk3kmhd6m1fam3ipr07-cura-appimage-tools-output-5.10.0-extracted/etc/xdg/menus/kf5-applications.menu
cinnamon-common.out                               5,230 r /nix/store/z9lhwym1w634mynx6vq3z5mj77gxjd6g-cinnamon-common-6.4.7/etc/xdg/menus/cinnamon-applications.menu

Thank you for the suggestion. However, the main goal of the overlay was specifically to reduce dependencies on other KDE modules that aren’t directly needed.
While plasma-workspace might work as a solution, I’d prefer to avoid introducing dependencies on the broader Plasma desktop environment when the core functionality can potentially be achieved with minimal dependencies.

I noticed that libsForQt5.kservice is already included in the install, and its only purpose here is for creating the application list which seem to include all of the desktop entries.

Hello - I was researching dolphin’s MIME issues when I came across this thread. Thank you for sharing this excellent overlay!
However, after using this, I encountered an issue where some themes became corrupted.


The left image shows the state before applying the overlay, while the right shows the state after.
Has anyone else experienced a similar problem?

1 Like

I had the same issue with Krusader. I was able to fix it in a weird way, but it works so far.
Using Hyprland on NixOS, flake-based setup using home-manager, nixpkgs-unstable.

The steps i went through (i randomly rebooted inbetween steps based on gut feeling):

  1. add pkgs.krusader to home.nix:
    home.packages = with pkgs; [
         # ...
         pkgs.krusader
         # other kdePackages i had installed prior
         # dont know if they are needed, just in case
         kdePackages.qtsvg
         kdePackages.gwenview
         kdePackages.kcalc
         # ...
    ];
    
  2. sudo nixos-rebuild switch --flake ~/.flake-dir"
  3. add following to home.nix:
    xdg.configFile."menus/applications.menu".text = builtins.readFile ./applications.menu;
    
  4. create a new file called applications.menu in the same directory as home.nix with the following content (copied from here):
    <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
      "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">
    
    <Menu>
    	<Name>Applications</Name>
    	<Directory>kde-main.directory</Directory>
    	<!-- Search the default locations -->
    	<DefaultAppDirs/>
    	<DefaultDirectoryDirs/>
    	<DefaultLayout>
    		<Merge type="menus"/>
    		<Merge type="files"/>
    		<Separator/>
    		<Menuname>More</Menuname>
    	</DefaultLayout>
    	<Layout>
    		<Merge type="menus"/>
    		<Menuname>Applications</Menuname>
    		<Merge type="files"/>
    	</Layout>
    
    	<Menu>
    		<Name>Applications</Name>
    		<Directory>kf5-unknown.directory</Directory>
    		<OnlyUnallocated/>
    		<Include>
    			<Not>
    				<!-- Don't list non-KDE core applications -->
    				<And>
    					<Category>Core</Category>
    					<Not><Category>KDE</Category></Not>
    				</And>
    				<!-- Don't list SUSE's YaST in here -->
    				<Category>X-SuSE-YaST</Category>
    				<Category>X-KDE-settings-hardware</Category>
    				<Category>X-KDE-settings-accessibility</Category>
    				<Category>X-KDE-settings-components</Category>
    				<Category>X-KDE-settings-desktop</Category>
    				<Category>X-KDE-settings-looknfeel</Category>
    				<Category>X-KDE-settings-network</Category>
    				<Category>X-KDE-settings-webbrowsing</Category>
    				<Category>X-KDE-settings-peripherals</Category>
    				<Category>X-KDE-settings-hardware</Category>
    				<Category>X-KDE-settings-power</Category>
    				<Category>X-KDE-settings-security</Category>
    				<Category>X-KDE-settings-sound</Category>
    				<Category>X-KDE-settings-system</Category>
    				<Category>X-KDE-information</Category>
    				<Filename>kde-kcm_knetworkconfmodule_ss.desktop</Filename>
    				<Filename>kde-medianotifications.desktop</Filename>
    				<Filename>kde-audioencoding.desktop</Filename>
    			</Not>
    		</Include>
    	</Menu>
    	<Menu>
    		<Name>Development</Name>
    		<Directory>kf5-development.directory</Directory>
    		<Menu>
    			<Name>Translation</Name>
    			<Directory>kf5-development-translation.directory</Directory>
    			<Include>
    				<And>
    					<Category>Development</Category>
    					<Category>Translation</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Web Development</Name>
    			<Directory>kf5-development-webdevelopment.directory</Directory>
    			<Include>
    				<And>
    					<Category>Development</Category>
    					<Category>WebDevelopment</Category>
    				</And>
    			</Include>
    		</Menu>
                    <Include>
    					<And>
                            <Category>Development</Category>
                            <Not><Category>Translation</Category></Not>
                            <Not><Category>WebDevelopment</Category></Not>
    					</And>
                    </Include>
            </Menu>
    	<Menu>
    		<Name>Science</Name>
    		<Directory>kf5-science.directory</Directory>
    		<Include>
    			<And><!-- Include /any/ Science app which is not an Education app -->
    				<Or>
    					<Category>Astronomy</Category>
    					<Category>Biology</Category>
    					<Category>Chemistry</Category>
    					<Category>Geology</Category>
    					<Category>MedicalSoftware</Category>
    					<Category>Physics</Category>
    					<Category>Math</Category>
    					<Category>Science</Category>
    				</Or>
    				<Not><Category>Education</Category></Not>
    			</And>
    		</Include>
    	</Menu>
    	<Menu>
    		<Name>Education</Name>
    		<Directory>kf5-education.directory</Directory>
    		<Menu>
    			<Name>Languages</Name>
    			<Directory>kf5-edu-languages.directory</Directory>
    			<Include>
    				<And>
    					<Category>Education</Category>
    					<Category>Languages</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Mathematics</Name>
    			<Directory>kf5-edu-mathematics.directory</Directory>
    			<Include>
    				<And>
    					<Category>Education</Category>
    					<Category>Math</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Miscellaneous</Name>
    			<Directory>kf5-edu-miscellaneous.directory</Directory>
    			<Include>
    				<And>
    					<Category>Education</Category>
    					<Not>
    						<Category>Languages</Category>
    						<Category>Math</Category>
    						<Category>Science</Category>
    						<Category>Teaching</Category>
    					</Not>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Science</Name>
    			<Directory>kf5-edu-science.directory</Directory>
    			<Include>
    				<And>
    					<Category>Education</Category>
    					<Category>Science</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Tools</Name>
    			<Directory>kf5-edu-tools.directory</Directory>
    			<Include>
    				<And>
    					<Category>Education</Category>
    					<Category>Teaching</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Games</Name>
    		<Directory>kf5-games.directory</Directory>
    		<Menu>
    			<Name>Arcade</Name>
    			<Directory>kf5-games-arcade.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>ArcadeGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Board</Name>
    			<Directory>kf5-games-board.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>BoardGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Card</Name>
    			<Directory>kf5-games-card.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>CardGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Kidsgames</Name>
    			<Directory>kf5-games-kids.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>KidsGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>TacticStrategy</Name>
    			<Directory>kf5-games-strategy.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>StrategyGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>Logic</Name>
    			<Directory>kf5-games-logic.directory</Directory>
    			<Include>
    				<And>
    					<Category>Game</Category>
    					<Category>LogicGame</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Include>
    			<And>
    				<Category>Game</Category>
    				<Not>
    					<Category>ArcadeGame</Category>
    					<Category>BoardGame</Category>
    					<Category>CardGame</Category>
    					<Category>KidsGame</Category>
    					<Category>StrategyGame</Category>
    					<Category>LogicGame</Category>
    				</Not>
    			</And>
    		</Include>
    	</Menu>
    	<Menu>
    		<Name>Graphics</Name>
    		<Directory>kf5-graphics.directory</Directory>
    		<Include>
    			<And>
    				<Category>Graphics</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    		</Include>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>Graphics</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Internet</Name>
    		<Directory>kf5-internet.directory</Directory>
    		<Include>
    			<And>
    				<Category>Network</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    		</Include>
    		<Menu>
    			<Name>Terminal</Name>
    			<Directory>kf5-internet-terminal.directory</Directory>
    		</Menu>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>Network</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Multimedia</Name>
    		<Directory>kf5-multimedia.directory</Directory>
    		<Include>
    			<And>
    				<Category>AudioVideo</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    		</Include>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>AudioVideo</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Office</Name>
    		<Directory>kf5-office.directory</Directory>
    		<Layout>
    			<Merge type="menus"/>
    			<Filename>kde-koshell.desktop</Filename>
    			<Filename>kde-Kontact.desktop</Filename>
    			<Separator/>
    			<Filename>kde-kword.desktop</Filename>
    			<Filename>kde-kspread.desktop</Filename>
    			<Filename>kde-kpresenter.desktop</Filename>
    			<Merge type="files"/>
    			<Separator/>
    			<Menuname>More</Menuname>
    		</Layout>
    		<Include>
    			<And>
    				<Category>Office</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    		</Include>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>Office</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Settingsmenu</Name>
    		<Directory>kf5-settingsmenu.directory</Directory>
    		<Include>
    			<Category>Settings</Category>
    		</Include>
    	</Menu>
    	<Menu>
    		<Name>System</Name>
    		<Directory>kf5-system.directory</Directory>
    		<Include>
    			<And>
    				<Category>System</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    		</Include>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>System</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    		<Menu>
    			<Name>ScreenSavers</Name>
    			<Directory>kf5-system-screensavers.directory</Directory>
    		</Menu>
    		<Menu>
    			<Name>Terminal</Name>
    			<Directory>kf5-system-terminal.directory</Directory>
    		</Menu>
    	</Menu>
    	<Menu>
    		<Name>Utilities</Name>
    		<Directory>kf5-utilities.directory</Directory>
    		<Include>
    			<And>
    				<Category>Utility</Category>
    				<Not><Category>X-KDE-More</Category></Not>
    			</And>
    			<Category>TextEditor</Category>
    			<Category>Accessibility</Category>
    			<Category>X-KDE-Utilities-Desktop</Category>
    			<Category>X-KDE-Utilities-File</Category>
    			<Category>X-KDE-Utilities-Peripherals</Category>
    			<Category>X-KDE-Utilities-PIM</Category>
    		</Include>
    		<Menu>
    			<Name>XUtilities</Name>
    			<Directory>kf5-utilities-xutils.directory</Directory>
    		</Menu>
    		<Menu>
    			<Name>More</Name>
    			<Directory>kf5-more.directory</Directory>
    			<Include>
    				<And>
    					<Category>Utility</Category>
    					<Category>X-KDE-More</Category>
    				</And>
    			</Include>
    		</Menu>
    	</Menu>
    	<Include>
    		<And>
    			<Category>KDE</Category>
    			<Category>Core</Category>
    		</And>
    	</Include>
    	<DefaultMergeDirs/>
    	<MergeFile>applications-kmenuedit.menu</MergeFile>
    </Menu>
    
  5. sudo nixos-rebuild switch --flake ~/.flake-dir"
  6. open Krusader
  7. open a png
  8. in the open dialogue enter gwenview and tick the checkbox reading ā€œRemember application association etc.ā€ (This is what i did, probably works using any filetype with a fitting viewer, but who knows)
  9. right-click another file > Open With > Other…
  10. now the installed applications should magically appear in the open dialogue, for some reason
  11. png and other image files should open in gwenview without showing the open dialogue, for some reason

This has worked for me and hasn’t yet broken (last 2 hours).

Edit: also works when using rofi to launch Krusader afterwards

Rather than grafting the behemoth plasma-applications.menu file from the KDE packages and adding those as build dependencies, I think the more proper and minimalist solution is to just create a small .menu file of our own, following the Freedesktop menu spec. This also gives you full customizability (adding submenus, changing icons, etc) if you want to get fancy with it. See here for reference.

Here’s what I did. No fancy menus, just shows all installed .desktop files in one flat list. See comments for what each tag does:

  environment.systemPackages = [ (pkgs.writeTextFile {
    name = "minimal-applications-menu";
    text = ''
      <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
       "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">

      <Menu>
        <Name>Applications</Name>

        <!-- Search the default directories for .desktop files.
             I.e. the /applications subdirectory of each entry in
             $XDG_DATA_DIRS
        -->
        <DefaultAppDirs/>

        <!-- Menus and submenus can use localized names as well as icons
             by referring to a .directory file. This configuration does
             not use them, but add it to the search for future-proofing.
        -->
        <DefaultDirectoryDirs/>

        <!-- Add every .desktop entry in the search result to this
             menu.
        -->
        <Include><All/></Include>

        <!-- List submenus before normal .desktop files in the menu. -->
        <DefaultLayout>
          <Merge type="menus"/>
          <Merge type="files" />
        </DefaultLayouts>

        <!-- Applications can add their own menu entries in
             menus/applications-merged/. This will cause them to
             be merged into this menu.
        -->
        <DefaultMergeDirs/>
      </Menu>
    '';
    destination = "/etc/xdg/menus/applications.menu";
    })  ];

This has the added benefit of not requiring you to set XDG_MENU_PREFIX=plasma-, or perform other tricks to make Dolphin/kbuildsycoca6 believe you are running a full KDE environment. So make sure to leave XDG_MENU_PREFIX unset.

Or, alternatively, you could set it to something matching your environment and change the filename of the .menu file above. For example: With XDG_MENU_PREFIX=niri-, change the filename to /etc/xdg/menus/niri-applications.menu.


EDIT:

After changing to this method after using the XDG_MENU_PREFIX=plasma- thing before, I did have to delete the ksycoca cache to force it to regenerate it using the new menu file. It’s located in $XDG_CACHE_HOME/ksycoca6_en_*.