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