Posting this for posterity, since I haven’t seen anyone put all these bits together in one place quite yet.
Greetd is packaged for NixOS, but not really well. The package works if you’re not setting it up to allow for a choice of multiple sessions, by using it the way most people use tuigreet - with the --cmd
option to specify the default command to execute after login. This works 100% fine if you only use one particular WM/DE session. However, I wanted greetd to detect both my sway session and my XFCE+i3 custom session.
By default, greetd checks /usr/share/xsessions and /usr/share/wayland-sessions for login sessions. Of course, these paths don’t exist on NixOS, so tuigreet tries and fails to find any sessions, and none can be selected from the ‘choose session’ menu.
{ config, pkgs, ...}:
{
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --sessions ${config.services.xserver.displayManager.sessionData.desktops}/share/xsessions:${config.services.xserver.displayManager.sessionData.desktops}/share/wayland-sessions --remember --remember-user-session";
user = "greeter";
};
};
};
}
There is one additional problem with this at the moment - greetd/tuigreet doesn’t set up the environment entirely properly for X11 (I don’t quite understand the specifics, feel free to write in with an explanation if you know and I might edit it in), so all X11 sessions must be wrapped with startx /usr/bin/env
. This currently has to be done manually, but is fixed in version 0.9.0, by adding an --xsession-wrapper
option, which by default wraps your X11 session properly.. This hasn’t been released, though, despite a commit being made for it on the tuigreet git, so the version in NixOS does not currently have this functionality. This update also separates --sessions
into --sessions
and --xsessions
, so that will need to be changed once the next release version comes out. (Aside - if you execute tuigreet --version
, you will see the version string says 0.7.3. I have verified that this is an upstream issue and not an out of date package - the developer simply forgot to change the version string for 0.8.0.)
And just to fully explain the command, --remember
and --remember-user-session
simply retain the last logged in user / session command - unsure if this overrides or is overridden by –cmd.