How to have two different desktop session configs?

I want to have the following two configs for a desktop session and be able to switch between the two via the display manager:

  • xmonad WM without a desktop manager
  • gnome3 ( without xmonad

Somehow I can’t get the combination to work. The relevant part of my current configuration.nix looks like this:

services.xserver = {
  enable = true;

  displayManager.defaultSession = "none+xmonad";

  desktopManager.gnome3.enable = true;
  desktopManager.gnome3.debug = true;

  windowManager.xmonad.enable = true;
  windowManager.xmonad.enableContribAndExtras = true;

This gets me into xmonad just fine. In the display manager I can even select a gnome session instead. However, if I do: I just land in xmonad anyway.

If I use gdm instead of the default display manager I can get into gnome just fine but I can’t select any alternative sessions.

Alternatively, I’ve also tried using pantheon with lightdm. That allows me to pick between a pantheon and an xmonad session but here I always land in pantheon.

Am I misunderstanding something? I’m still new to nix and nixos so I might be missing something obvious. Any ideas?

Hm, no problem here running sway and Gnome 3 (wayland). Think I’ve even had a parallel X and Wayland setup working before switching to Wayland.

This is my setup:

  services.xserver = {
    autorun = false;
    enable = true;
    xkbOptions = "ctrl:nocaps";
    displayManager.gdm.enable = true;
    desktopManager.gnome3.enable = true;

  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
    wrapperFeatures.base = true;
    extraPackages = with pkgs; [
      mako            # notification daemon
      swaylock        # idle lock
      swayidle        # idle lock
      wl-clipboard    # wl-copy, wl-paste
    extraSessionCommands = ''
      export XKB_DEFAULT_OPTIONS=ctrl:nocaps
      export MOZ_ENABLE_WAYLAND=1
      export XDG_CURRENT_DESKTOP=sway

Note that I don’t have defaultSession set, and manually start displayManager after booting.
Since sway doesn’t use displaymanager, now I wonder if that has to do anything with it.