greetd: Add autologin options

This commit is contained in:
NullBite 2024-05-10 21:31:44 -04:00
parent f4f8395e0e
commit 02ad5bd33f
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A

View File

@ -16,10 +16,26 @@ let
in
{
config = lib.mkIf cfg.enable {
assertions = lib.optionals cfg.settings.autologin [
{
assertion = ! builtins.isNull cfg.settings.autologinUser;
message = "greetd: Auto-login is enabled but no user is configured";
}
{
assertion = ! builtins.isNull cfg.settings.command;
message = "greetd: Auto-login is enabled but no login command is configured";
}
];
environment.systemPackages = [ loginwrap ];
services.greetd = {
enable = true;
settings = {
initial_session = lib.mkIf cfg.settings.autologin {
command = cfg.settings.finalCommand;
user = cfg.settings.autologinUser;
};
default_session = lib.mkMerge [
# tuigreet configuration
@ -69,7 +85,7 @@ in
command-login-wrapped = [ "loginwrap" ] ++ prevcmd;
cmd = if (builtins.isNull prevcmd) then null else
(if st.loginShell then command-login-wrapped else prevcmd);
in lib.escapeShellArgs cmd;
in if builtins.isNull cmd then null else lib.escapeShellArgs cmd;
readOnly = true;
};
command = lib.mkOption {
@ -96,6 +112,19 @@ in
default = "${pkgs.nixfiles-assets}/share/wallpapers/nixfiles-static/Djayjesse-finding_life.png";
example = "femboy-bee.png";
};
autologin = lib.mkOption {
description = "Whether to configure auto-login";
type = bool;
default = false;
example = true;
};
autologinUser = lib.mkOption {
description = "User to automatically log in";
type = nullOr str;
default = null;
example = "username";
};
};
presets.tuigreet.enable = lib.mkOption {
description = "tuigreet greetd configuration";