Jump to content

Greetd: Difference between revisions

From Official NixOS Wiki
Klinger (talk | contribs)
No edit summary
Phobos (talk | contribs)
m Reorganized and added ReGreet
 
Line 1: Line 1:
[https://git.sr.ht/~kennylevinsen/greetd greetd] is a minimal login manager.
[https://git.sr.ht/~kennylevinsen/greetd greetd] is a minimal and flexible login manager daemon.


== Usage ==
== Greeters ==


Using this configuration, greetd will use the greeter <code>gtkgreet</code>, asking for user, password and which session to start as defined in the <code>/etc/greetd/environments</code> file:
=== GTKGreet ===
Using this configuration, greetd will use the greeter [https://git.sr.ht/~kennylevinsen/gtkgreet gtkgreet], asking for user, password and which session to start as defined in the <code>/etc/greetd/environments</code> file:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
Line 36: Line 37:
</nowiki>}}
</nowiki>}}


{{note|1=<nowiki/>
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:
* Cage: https://github.com/Hjdskes/cage/issues/169#issuecomment-691659377
* Sway: https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
}}
=== ReGreet ===
[https://github.com/rharish101/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 [https://search.nixos.org/options?&query=regreet programs.regreet].
Installation is as simple as enabling it within your configuration.
{{File|3=programs.regreet.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}}
You can also style and configure ReGreet through Nix easily.
{{File|3=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";
};|name=/etc/nixos/configuration.nix|lang=nix}}
== Automatic startup ==
In this minimal example, the Wayland compositor [[Sway]] automatically gets executed by the user <code>myuser</code> after successfull boot, no password required:
In this minimal example, the Wayland compositor [[Sway]] automatically gets executed by the user <code>myuser</code> after successfull boot, no password required:


Line 52: Line 81:


<code>initial_session</code> is executed automatically. If you just define <code>default_session</code>, greetd will ask for a password and execute <code>command</code> with user <code>myuser</code>.
<code>initial_session</code> is executed automatically. If you just define <code>default_session</code>, greetd will ask for a password and execute <code>command</code> with user <code>myuser</code>.
{{note|1=<nowiki/>
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:
* Cage: https://github.com/Hjdskes/cage/issues/169#issuecomment-691659377
* Sway: https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
}}


[[Category:Wayland]]
[[Category:Wayland]]

Latest revision as of 03:36, 3 January 2026

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:

❄︎ /etc/nixos/configuration.nix
{ 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
  '';
}
Note:

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.

❄︎ /etc/nixos/configuration.nix
programs.regreet.enable = true;

You can also style and configure ReGreet through Nix easily.

❄︎ /etc/nixos/configuration.nix
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:

❄︎ /etc/nixos/configuration.nix
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.