Nix tools not available in Plasma Mobile wayland session

I just installed Debian 12 on my Surface Pro 6 tablet and have started to use the plasma mobile wayland session. However, I noticed that my nix tools are no longer available in the plasma mobile session. Even sourcing /etc/profile.d/nix.sh does not help (that is what normally sets the PATH to include the nix tools). This seems specific to plasma mobile because the nix tools are available when I switch to the normal plasma desktop session. What could be going wrong here?

I’ve also asked this question on the Nixos Discourse: Nix tools not available in Plasma Mobile wayland session - Help - NixOS Discourse

I’ve figured out an important detail: the plasma-mobile session sources /etc/profile twice. The first time it sets up the right PATH, but the second time it resets the PATH and the nix setup script checks that it is only executed once so it does not add the nix tools the second time around.

I opened a bug report: 503467 – /etc/profile runs twice on login

I’ve managed to find and fix the bug. The issue was that /etc/profile got loaded twice, once by the display manager and once by plasma mobile itself. The fix is t remove the line that sources /etc/profile from the /usr/bin/startplasmamobile script.