Letting home-manager handle the X session on Debian

I would like to have i3 window manager handled from home-manager in Debian but I can’t make it work: either Debian’s lightdm will disappear and show a black screen where I can’t do anything, or Debian’s lightdm will disappear and reappear immediately. I can’t find any log file with debug information.

I’m trying something like:

{
  xsession = {
    enable = true;
    windowManager.i3 = {
      enable = true;
      # ...
    };
  };
}

The same configuration works fine on NixOS.

/cc @rycee

The https://wiki.debian.org/Xsession page says

Finally, note that the ~/.xsession file is only read if you are using a Debian X session.

so you might need to select an X session in the DM?

The wiki page also says that Debian uses ~/.xsessionrc for unconditional session commands so if the above doesn’t work then you could try adding

xsession.scriptPath = ".xsessionrc";

to your configuration.

The systemd journal may contain output related to the session startup.