nixdots/system/roles/workstation/display/login/greetd.nix

64 lines
1.7 KiB
Nix
Raw Normal View History

2024-06-24 23:32:59 +00:00
{
config,
pkgs,
lib,
...
}: let
inherit (lib) mkIf getExe;
inherit (lib.strings) concatStringsSep;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
2024-06-25 00:10:39 +00:00
greetingMsg = "'Access is restricted to authorized personnel only.'";
tuiGreetTheme = "'border=magenta;text=cyan;prompt=green;time=red;action=white;button=yellow;container=black;input=gray'";
2024-06-24 23:32:59 +00:00
sessionData = config.services.displayManager.sessionData.desktops;
sessionPaths = concatStringsSep ":" [
"${sessionData}/share/xsessions"
"${sessionData}/share/wayland-sessions"
];
defaultSession = {
user = "greeter";
command = concatStringsSep " " [
(getExe pkgs.greetd.tuigreet)
"--time"
"--remember"
"--remember-user-session"
"--asterisks"
2024-06-25 00:10:39 +00:00
"--greeting ${greetingMsg}"
2024-06-24 23:32:59 +00:00
"--sessions '${sessionPaths}'"
2024-06-25 00:10:39 +00:00
"--theme ${tuiGreetTheme}"
2024-06-24 23:32:59 +00:00
];
};
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services.greetd = {
enable = true;
2024-06-25 00:10:39 +00:00
vt = 1;
2024-06-24 23:32:59 +00:00
# <https://man.sr.ht/~kennylevinsen/greetd/>
settings = {
# default session is what will be used if no session is selected
# in this case it'll be a TUI greeter
default_session = defaultSession;
};
};
# Suppress error messages on tuigreet. They sometimes obscure the TUI
# boundaries of the greeter.
# See: https://github.com/apognu/tuigreet/issues/68#issuecomment-1586359960
systemd.services.greetd.serviceConfig = {
Type = "idle";
StandardInputs = "tty";
StandardOutput = "tty";
StandardError = "journal";
TTYReset = true;
TTYVHangup = true;
TTYVTDisallocate = true;
};
};
}