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 (X.org) 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:

Summary
  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; [
      brightnessctl
      playerctl
      mako            # notification daemon
      swaylock        # idle lock
      swayidle        # idle lock
      yambar
      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.

@anticipatedfart Sorry to necrobump, but I’m having a similar issue and didn’t find clear info, have you ever solved it?

AFAICT from your config there is no (explicit) definition of the two sessions you want, so probably the windowManager definition overrides a part of the desktopManager definition? I may be wrong though…

In my case I have two windowManager sessions defined, and it appears that one (partly) overrides the other, so in my case enabling none+xmonad breaks none+instantwm

      displayManager = {
        defaultSession = "none+instantwm";
        session = [
          {
            manage = "window";
            name = "instantwm";
            start = ''
              startinstantos &
              waitPID=$!
            '';
          }
          {
            manage = "window";
            name = "xmonad";
            start = ''
              xmonad &
              waitPID=$!
            '';
          }
        ];
       ...

and in home.nix

  xsession = {
    enable = true;
    initExtra = extra + polybarOpts;

    windowManager.xmonad = {
      enable = true;
      enableContribAndExtras = true;
      extraPackages = hp: [
        hp.dbus
        hp.monad-logger
      ];
      config = ./config.hs;
    };
  };