Greetd
greetd is a minimal and flexible login manager daemon.
Greeters
GTKGreet
Using this configuration, greetd will use the greeter gtkgreet, asking for user, password and which session to start as defined in the /etc/greetd/environments file:
{ config, lib, pkgs, ... }:
let
swayConfig = pkgs.writeText "greetd-sway-config" ''
# `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
exec "${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; swaymsg exit"
bindsym Mod4+shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
-b 'Poweroff' 'systemctl poweroff' \
-b 'Reboot' 'systemctl reboot'
'';
in
{
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.sway}/bin/sway --config ${swayConfig}";
};
};
};
environment.etc."greetd/environments".text = ''
sway
fish
bash
startxfce4
'';
}
If you're hosting gtkgreet in a Wayland compositor, there is a known issue, between GTK portals and dbus, of a delay before the greeter appears,. There are a couple known workarounds depending on the compositor you're using:
ReGreet
ReGreet is a clean and customizable GTK-based greetd greeter written in Rust. It is meant to be run under a Wayland compositor, such as Sway. Configuration options may be found under programs.regreet.
Installation is as simple as enabling it within your configuration.
programs.regreet.enable = true;
You can also style and configure ReGreet through Nix easily.
programs.regreet = {
enable = true;
# For this example you'd need to have a version of Adwaita and the font Cantarell installed
theme.name = "Adwaita";
font = {
name = "Cantarell";
size = 16;
};
cursorTheme.name = "Adwaita";
};
Automatic startup
In this minimal example, the Wayland compositor Sway automatically gets executed by the user myuser after successfull boot, no password required:
services.greetd = {
enable = true;
settings = rec {
initial_session = {
command = "${pkgs.sway}/bin/sway";
user = "myuser";
};
default_session = initial_session;
};
};
initial_session is executed automatically. If you just define default_session, greetd will ask for a password and execute command with user myuser.