With this config, whenever I boot my PC, I expect it to log into Gnome Wayland because it was the last session I started. However, Gnome with X11 will start.
If I want it to start Gnome Wayland, I need to click my username in the GDM screen, and open the session selection. It has two entries: “Gnome” and “Gnome (X11)”. I need to click the “Gnome” entry which is already selected (!), close the session selection, then log in. Then Gnome will start with Wayland.
I fixed this by adding services.xserver.desktopManager.default = "gnome"; to my configuration.nix.
This Topic might be related because for me, this also happens since trying out KDE, I believe.
In the worst case, when GNOME Shell detects problems on startup, it will just fall back to X session regardless the value of services.xserver.displayManager.defaultSession.
But then, the only thing services.xserver.displayManager.defaultSession = "gnome" achieves is that Wayland session will be tried every time. There will not be any guarantee of not falling back on XOrg until the underlying issue (e.g. buggy extension, GPU driver issues, Shell bug…) is resolved.
Not really. You could try patching the appropriate packages to remove the xorg session files but GNOME currently does not support building without X server – Mutter support for that has only just been merged – so if the fallback session were to be not found, it would probably break horribly.