nixpkgs/nixos/modules/services/display-managers/greetd.nix
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00

120 lines
3.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.greetd;
tty = "tty${toString cfg.vt}";
settingsFormat = pkgs.formats.toml { };
in
{
options.services.greetd = {
enable = mkEnableOption "greetd, a minimal and flexible login manager daemon";
package = mkPackageOption pkgs [ "greetd" "greetd" ] { };
settings = mkOption {
type = settingsFormat.type;
example = literalExpression ''
{
default_session = {
command = "''${pkgs.greetd.greetd}/bin/agreety --cmd sway";
};
}
'';
description = ''
greetd configuration ([documentation](https://man.sr.ht/~kennylevinsen/greetd/))
as a Nix attribute set.
'';
};
vt = mkOption {
type = types.int;
default = 1;
description = ''
The virtual console (tty) that greetd should use. This option also disables getty on that tty.
'';
};
restart = mkOption {
type = types.bool;
default = !(cfg.settings ? initial_session);
defaultText = literalExpression "!(config.services.greetd.settings ? initial_session)";
description = ''
Whether to restart greetd when it terminates (e.g. on failure).
This is usually desirable so a user can always log in, but should be disabled when using 'settings.initial_session' (autologin),
because every greetd restart will trigger the autologin again.
'';
};
};
config = mkIf cfg.enable {
services.greetd.settings.terminal.vt = mkDefault cfg.vt;
services.greetd.settings.default_session.user = mkDefault "greeter";
security.pam.services.greetd = {
allowNullPassword = true;
startSession = true;
enableGnomeKeyring = mkDefault config.services.gnome.gnome-keyring.enable;
};
# This prevents nixos-rebuild from killing greetd by activating getty again
systemd.services."autovt@${tty}".enable = false;
# Enable desktop session data
services.displayManager.enable = lib.mkDefault true;
systemd.services.greetd = {
aliases = [ "display-manager.service" ];
unitConfig = {
Wants = [
"systemd-user-sessions.service"
];
After = [
"systemd-user-sessions.service"
"plymouth-quit-wait.service"
"getty@${tty}.service"
];
Conflicts = [
"getty@${tty}.service"
];
};
serviceConfig = {
ExecStart = "${pkgs.greetd.greetd}/bin/greetd --config ${settingsFormat.generate "greetd.toml" cfg.settings}";
Restart = mkIf cfg.restart "on-success";
# Defaults from greetd upstream configuration
IgnoreSIGPIPE = false;
SendSIGHUP = true;
TimeoutStopSec = "30s";
KeyringMode = "shared";
Type = "idle";
};
# Don't kill a user session when using nixos-rebuild
restartIfChanged = false;
wantedBy = [ "graphical.target" ];
};
systemd.defaultUnit = "graphical.target";
# Create directories potentially required by supported greeters
# See https://github.com/NixOS/nixpkgs/issues/248323
systemd.tmpfiles.rules = [
"d '/var/cache/tuigreet' - greeter greeter - -"
];
users.users.greeter = {
isSystemUser = true;
group = "greeter";
};
users.groups.greeter = { };
};
meta.maintainers = with maintainers; [ queezle ];
}