From 8ea20e5812c26c1f852e5102b64eddce14070e67 Mon Sep 17 00:00:00 2001 From: Zachary Arnaise <121795280+zacharyarnaise@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:14:44 +0100 Subject: [PATCH] nixos/ly: add support for auto-login --- .../modules/services/display-managers/ly.nix | 35 +++++++++++++++---- nixos/tests/ly.nix | 20 +++++++++++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/display-managers/ly.nix b/nixos/modules/services/display-managers/ly.nix index 368a067a4d9a..43292a40149d 100644 --- a/nixos/modules/services/display-managers/ly.nix +++ b/nixos/modules/services/display-managers/ly.nix @@ -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 = { diff --git a/nixos/tests/ly.nix b/nixos/tests/ly.nix index a9c74c5f3ca7..2d9303308001 100644 --- a/nixos/tests/ly.nix +++ b/nixos/tests/ly.nix @@ -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)