1 { config, lib, pkgs, ... }:
3 cfg = config.services.greetd;
4 tty = "tty${toString cfg.vt}";
5 settingsFormat = pkgs.formats.toml { };
8 options.services.greetd = {
9 enable = lib.mkEnableOption "greetd, a minimal and flexible login manager daemon";
11 package = lib.mkPackageOption pkgs [ "greetd" "greetd" ] { };
13 settings = lib.mkOption {
14 type = settingsFormat.type;
15 example = lib.literalExpression ''
18 command = "''${pkgs.greetd.greetd}/bin/agreety --cmd sway";
23 greetd configuration ([documentation](https://man.sr.ht/~kennylevinsen/greetd/))
24 as a Nix attribute set.
28 greeterManagesPlymouth = lib.mkOption {
29 type = lib.types.bool;
33 Don't configure the greetd service to wait for Plymouth to exit.
35 Enable this if the greeter you're using can manage Plymouth itself to provide a smoother handoff.
43 The virtual console (tty) that greetd should use. This option also disables getty on that tty.
47 restart = lib.mkOption {
48 type = lib.types.bool;
49 default = !(cfg.settings ? initial_session);
50 defaultText = lib.literalExpression "!(config.services.greetd.settings ? initial_session)";
52 Whether to restart greetd when it terminates (e.g. on failure).
53 This is usually desirable so a user can always log in, but should be disabled when using 'settings.initial_session' (autologin),
54 because every greetd restart will trigger the autologin again.
58 config = lib.mkIf cfg.enable {
60 services.greetd.settings.terminal.vt = lib.mkDefault cfg.vt;
61 services.greetd.settings.default_session.user = lib.mkDefault "greeter";
63 security.pam.services.greetd = {
64 allowNullPassword = true;
66 enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable;
69 # This prevents nixos-rebuild from killing greetd by activating getty again
70 systemd.services."autovt@${tty}".enable = false;
72 # Enable desktop session data
73 services.displayManager.enable = lib.mkDefault true;
75 systemd.services.greetd = {
76 aliases = [ "display-manager.service" ];
80 "systemd-user-sessions.service"
83 "systemd-user-sessions.service"
84 "getty@${tty}.service"
85 ] ++ lib.optionals (!cfg.greeterManagesPlymouth) [
86 "plymouth-quit-wait.service"
89 "getty@${tty}.service"
94 ExecStart = "${pkgs.greetd.greetd}/bin/greetd --config ${settingsFormat.generate "greetd.toml" cfg.settings}";
96 Restart = lib.mkIf cfg.restart "on-success";
98 # Defaults from greetd upstream configuration
99 IgnoreSIGPIPE = false;
101 TimeoutStopSec = "30s";
102 KeyringMode = "shared";
107 # Don't kill a user session when using nixos-rebuild
108 restartIfChanged = false;
110 wantedBy = [ "graphical.target" ];
113 systemd.defaultUnit = "graphical.target";
115 # Create directories potentially required by supported greeters
116 # See https://github.com/NixOS/nixpkgs/issues/248323
117 systemd.tmpfiles.rules = [
118 "d '/var/cache/tuigreet' - greeter greeter - -"
121 users.users.greeter = {
126 users.groups.greeter = { };
129 meta.maintainers = with lib.maintainers; [ queezle ];