at 23.11-pre 1.3 kB view raw
1{ config, lib, ... }: 2 3let 4 dmcfg = config.services.xserver.displayManager; 5 cfg = config.test-support.displayManager.auto; 6in 7{ 8 9 ###### interface 10 11 options = { 12 test-support.displayManager.auto = { 13 enable = lib.mkOption { 14 default = false; 15 description = lib.mdDoc '' 16 Whether to enable the fake "auto" display manager, which 17 automatically logs in the user specified in the 18 {option}`user` option. This is mostly useful for 19 automated tests. 20 ''; 21 }; 22 23 user = lib.mkOption { 24 default = "root"; 25 description = lib.mdDoc "The user account to login automatically."; 26 }; 27 }; 28 }; 29 30 ###### implementation 31 32 config = lib.mkIf cfg.enable { 33 services.xserver.displayManager = { 34 lightdm.enable = true; 35 autoLogin = { 36 enable = true; 37 user = cfg.user; 38 }; 39 }; 40 41 # lightdm by default doesn't allow auto login for root, which is 42 # required by some nixos tests. Override it here. 43 security.pam.services.lightdm-autologin.text = lib.mkForce '' 44 auth requisite pam_nologin.so 45 auth required pam_succeed_if.so quiet 46 auth required pam_permit.so 47 48 account include lightdm 49 50 password include lightdm 51 52 session include lightdm 53 ''; 54 }; 55}