nixos/ly: add support for auto-login

This commit is contained in:
Zachary Arnaise 2026-01-28 19:14:44 +01:00
commit 8ea20e5812
No known key found for this signature in database
GPG key ID: 04978F5A657CA5AB
2 changed files with 48 additions and 7 deletions

View file

@ -17,13 +17,14 @@ let
iniFmt = pkgs.formats.iniWithGlobalSection { };
inherit (lib)
concatMapStrings
attrNames
concatMapStrings
getAttr
mkIf
mkOption
mkEnableOption
mkPackageOption
optionalAttrs
;
xserverWrapper = pkgs.writeShellScript "xserver-wrapper" ''
@ -47,6 +48,11 @@ let
setup_cmd = dmcfg.sessionData.wrapper;
brightness_up_cmd = "${lib.getExe pkgs.brightnessctl} -q -n s +10%";
brightness_down_cmd = "${lib.getExe pkgs.brightnessctl} -q -n s 10%-";
}
// optionalAttrs dmcfg.autoLogin.enable {
auto_login_service = "ly-autologin";
auto_login_session = dmcfg.sessionData.autologinSession;
auto_login_user = dmcfg.autoLogin.user;
};
finalConfig = defaultConfig // cfg.settings;
@ -84,17 +90,32 @@ in
assertions = [
{
assertion = !dmcfg.autoLogin.enable;
assertion = dmcfg.autoLogin.enable -> dmcfg.sessionData.autologinSession != null;
message = ''
ly doesn't support auto login.
ly auto-login requires that services.displayManager.defaultSession is set.
'';
}
];
security.pam.services.ly = {
startSession = true;
unixAuth = true;
enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable;
security.pam.services = {
ly = {
startSession = true;
unixAuth = true;
enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable;
};
}
// optionalAttrs dmcfg.autoLogin.enable {
ly-autologin.text = ''
auth requisite pam_nologin.so
auth required pam_succeed_if.so uid >= 1000 quiet
auth required pam_permit.so
account include ly
password include ly
session include ly
'';
};
environment = {

View file

@ -23,6 +23,18 @@ in
services.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
};
nodes.machineAutologin =
{ ... }:
lib.attrsets.recursiveUpdate machineBase {
services.displayManager.ly.x11Support = true;
services.xserver.enable = true;
services.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
};
nodes.machineNoX11 =
{ ... }:
lib.attrsets.recursiveUpdate machineBase {
@ -83,6 +95,14 @@ in
machine.sleep(2)
machine.screenshot("icewm")
machineAutologin.wait_until_succeeds("getfacl /dev/dri/card0 | grep video")
machineAutologin.send_key("ctrl-alt-f1")
machineAutologin.wait_for_file("/run/user/${toString user.uid}/lyxauth")
machineAutologin.succeed("xauth merge /run/user/${toString user.uid}/lyxauth")
machineAutologin.wait_for_window("^IceWM ")
machineAutologin.sleep(2)
machineAutologin.screenshot("autologin-icewm")
machineNoX11.wait_until_tty_matches("1", "password")
machineNoX11.send_key("ctrl-alt-f1")
machineNoX11.sleep(1)