nixpkgs-suyu/nixos/modules/services/display-managers/greetd.nix
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00

111 lines
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";
package = mkOption {
type = types.package;
default = pkgs.greetd.greetd;
defaultText = literalExpression "pkgs.greetd.greetd";
description = lib.mdDoc "The greetd package that should be used.";
};
settings = mkOption {
type = settingsFormat.type;
example = literalExpression ''
{
default_session = {
command = "''${pkgs.greetd.greetd}/bin/agreety --cmd sway";
};
}
'';
description = lib.mdDoc ''
greetd configuration ([documentation](https://man.sr.ht/~kennylevinsen/greetd/))
as a Nix attribute set.
'';
};
vt = mkOption {
type = types.int;
default = 1;
description = lib.mdDoc ''
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 = lib.mdDoc ''
Wether 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;
};
# This prevents nixos-rebuild from killing greetd by activating getty again
systemd.services."autovt@${tty}".enable = false;
systemd.services.greetd = {
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 "always";
# Defaults from greetd upstream configuration
IgnoreSIGPIPE = false;
SendSIGHUP = true;
TimeoutStopSec = "30s";
KeyringMode = "shared";
};
# Don't kill a user session when using nixos-rebuild
restartIfChanged = false;
wantedBy = [ "graphical.target" ];
};
systemd.defaultUnit = "graphical.target";
users.users.greeter = {
isSystemUser = true;
group = "greeter";
};
users.groups.greeter = {};
};
meta.maintainers = with maintainers; [ queezle ];
}