How can I prevent displayManager trying to start session recorded in AccountService config?

So I have 2 profiles, one use plasma-desktop, and the other use pantheon. After logged in this line Xsession=plasma or Session=pantheon will be added to /var/lib/AccountsService/users/<username>. When I switch to one profile from another without deleting this line I can’t start the session because it will try to start the session recorded in that file and can’t find it. How can I disable this behavior?

Hi, I’m not sure this would be an issue with AccountsService.

And can you also define a profile?
This can have a different meaning in the context in NixOS, such as
a NixOS profile.

Other question would be what display manager you are using
and are you switching the session within it?

I have two separate configurations, one enables plasma desktop and the other one enables pantheon desktop. By saying profile I mean the two boot entry created by the two configurations respectively, e.g. nixos-rebuild -p Plasma -I nixos-config=/path/to/plasma/config, so I’m using lightdm however not switching session within it but select a different entry in grub menu.
I’m also not sure if it is AccountsService that should be blamed but if I set services.accounts-daemon.enable = mkForce false;, the issue is gone. However I don’t want to disable all functionalities provided by AccountsService, only this behavior.

Ahh I think I understand.

You’ll probably want to set

services.xserver.desktopManager.default = mkForce "pantheon";

in your pantheon config and

services.xserver.desktopManager.default = mkForce "plasma5";

in your plasma config or you’ll have to manually switch the session that
lightdm starts at login.

There actually isn’t a problem here it’s just the services
in use aren’t intended to be used this way.

Yeah I would advise you not to do that. It would break many other things.

But services.xserver.desktopManager.default has already be set to “pantheon” when I enabled patheon desktop, however, it will still try to load the plasma session if the line I mentioned appears in the AccountsService config…

By setting that it will affect lightdm’s configuration to include

user-session=pantheon

(vice versa)

this overrides the default session that lightdm will start completely to what session is specified.

LightDM - Ubuntu Wiki

Anything else will be ignored.