at master 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 = '' 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 = "The user account to login automatically."; 26 }; 27 }; 28 }; 29 30 ###### implementation 31 32 config = lib.mkIf cfg.enable { 33 services.xserver.displayManager.lightdm.enable = true; 34 services.displayManager.autoLogin = { 35 enable = true; 36 user = cfg.user; 37 }; 38 39 # lightdm by default doesn't allow auto login for root, which is 40 # required by some nixos tests. Override it here. 41 security.pam.services.lightdm-autologin.text = lib.mkForce '' 42 auth requisite pam_nologin.so 43 auth required pam_succeed_if.so quiet 44 auth required pam_permit.so 45 46 account include lightdm 47 48 password include lightdm 49 50 session include lightdm 51 ''; 52 }; 53}