Using only sway with gdm


I am test-driving nixos on my machine and I try to deploy sway with gdm and but without gnome.
I applied the info of the wiki page (Sway - NixOS Wiki) but it does not talk about the integration with gdm.

When I activate gdm and sway, the sway.desktop file defining the sway wayland session is not seen by gdm. I tried the following:

  services.xserver = {
    enable = true;
    displayManager.gdm.enable = true;
    displayManager.gdm.wayland = true;
    displayManager.sessionPackages = [ pkgs.sway ];
    libinput.enable = true;

When I do this, gdm does not start as it does not find any session files.

For gnome I found that adding gnome.gnome-session.sessions to the sessionPackages gnome is correctly seen so I think it is related content of the sway package. The sway.desktop file is in the nix store.

Any idea of how I shall solve that ?

Sway has it’s own configuration options which add itself to displayManager.sessionPackages automatically. Try setting programs.sway.enable. You can see it uses a custom version of sway here:

And it’s added to the sessionPackages here:

Unfortunately programs.sway.enable was already at true and still it didn’t work.
I put a stripped down version of my flake configuration to demonstrate the issue:

Maybe there is something wrong when I manipulate the imports. I run nixos-rebuild switch --flake. #salm to apply the configuration.

I also tried to remove the flake and setup a classic configuration in /etc/nixos (keeping the imports) but it behaves the same way.

Just checked sddm instead of gdm and it worked so there is something wrong with gdm + sway combination.

GDM uses GNOME Shell for its UI so it probably will not work without at least the minimal gnome-shell being installed.

This shouldn’t be the case. I made a package for Vivarium and with just that session file I was able to add a desktop entry to GDM. Only other session I have is XMonad (no Gnome at all). I have an old profile for Sway, I don’t use it anymore but I’ll build it and see if I can get it to show up in GDM later on. It used to work fine :man_shrugging:

@nrdxp thank you for the time taken.

How can I check the path used by gdm in nixos to retrieve the session installed ? I don’t know how to get the actual wayland-sessions directory it reads.

Looks like you we are actually adding GNOME Shell in the module so it might work:

Though this configuration is not tested so it might be broken.

Strange, I tried it and my old sway profile still works fine with GDM. Only other sessions I’ve got in there are the aforementioned Vivarium and Xmonad.

Tried it with a dead simple configuration generated with nixos-generate-config and simply added:

services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true;
programs.sway.enable = true;

Still the same behaviour gdm does not start, it coredumps with a message saying it did not find any session file.

I tried a fresh start and I confirm the behavior. After installing using the livecd, disabling gnome and enabling only sway makes gdm not starting. If I keep gnome it is ok.

Tried lightdm but it has scaling issues on hidpi and does not start sway on the first login.

I ended up switching to greetd instead of gdm.