nixos/lightdm: support greeter-less auto login
This adds configuration options for automatic login and disabling the greeter (this should avoid the dependency on gtk).
This commit is contained in:
parent
8881f940a9
commit
336786addc
|
@ -4,7 +4,8 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
dmcfg = config.services.xserver.displayManager;
|
xcfg = config.services.xserver;
|
||||||
|
dmcfg = xcfg.displayManager;
|
||||||
xEnv = config.systemd.services."display-manager".environment;
|
xEnv = config.systemd.services."display-manager".environment;
|
||||||
cfg = dmcfg.lightdm;
|
cfg = dmcfg.lightdm;
|
||||||
|
|
||||||
|
@ -36,16 +37,31 @@ let
|
||||||
lightdmConf = writeText "lightdm.conf"
|
lightdmConf = writeText "lightdm.conf"
|
||||||
''
|
''
|
||||||
[LightDM]
|
[LightDM]
|
||||||
greeter-user = ${config.users.extraUsers.lightdm.name}
|
${optionalString cfg.greeter.enable ''
|
||||||
greeters-directory = ${cfg.greeter.package}
|
greeter-user = ${config.users.extraUsers.lightdm.name}
|
||||||
|
greeters-directory = ${cfg.greeter.package}
|
||||||
|
''}
|
||||||
sessions-directory = ${dmcfg.session.desktops}
|
sessions-directory = ${dmcfg.session.desktops}
|
||||||
|
|
||||||
[Seat:*]
|
[Seat:*]
|
||||||
xserver-command = ${xserverWrapper}
|
xserver-command = ${xserverWrapper}
|
||||||
session-wrapper = ${dmcfg.session.script}
|
session-wrapper = ${dmcfg.session.script}
|
||||||
greeter-session = ${cfg.greeter.name}
|
${optionalString cfg.greeter.enable ''
|
||||||
|
greeter-session = ${cfg.greeter.name}
|
||||||
|
''}
|
||||||
|
${optionalString cfg.autoLogin.enable ''
|
||||||
|
autologin-user = ${cfg.autoLogin.user}
|
||||||
|
autologin-user-timeout = ${toString cfg.autoLogin.timeout}
|
||||||
|
autologin-session = ${defaultSessionName}
|
||||||
|
''}
|
||||||
${cfg.extraSeatDefaults}
|
${cfg.extraSeatDefaults}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
defaultSessionName =
|
||||||
|
let
|
||||||
|
dm = xcfg.desktopManager.default;
|
||||||
|
wm = xcfg.windowManager.default;
|
||||||
|
in dm + optionalString (wm != "none") (" + " + wm);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Note: the order in which lightdm greeter modules are imported
|
# Note: the order in which lightdm greeter modules are imported
|
||||||
|
@ -68,6 +84,14 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
greeter = {
|
greeter = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
If set to false, run lightdm in greeterless mode. This only works if autologin
|
||||||
|
is enabled and autoLogin.timeout is zero.
|
||||||
|
'';
|
||||||
|
};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -102,10 +126,67 @@ in
|
||||||
description = "Extra lines to append to SeatDefaults section.";
|
description = "Extra lines to append to SeatDefaults section.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
autoLogin = mkOption {
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Configuration for automatic login.
|
||||||
|
'';
|
||||||
|
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Automatically log in as the specified <option>autoLogin.user</option>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
User to be used for the automatic login.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
timeout = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 0;
|
||||||
|
description = ''
|
||||||
|
Show the greeter for this many seconds before automatic login occurs.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
assertions = [
|
||||||
|
{ assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null;
|
||||||
|
message = ''
|
||||||
|
LightDM auto-login requires services.xserver.displayManager.lightdm.autoLogin.user to be set
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{ assertion = cfg.autoLogin.enable -> elem defaultSessionName dmcfg.session.names;
|
||||||
|
message = ''
|
||||||
|
LightDM auto-login requires that services.xserver.desktopManager.default and
|
||||||
|
services.xserver.windowMananger.default are set to valid values. The current
|
||||||
|
default session: ${defaultSessionName} is not valid.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{ assertion = !cfg.greeter.enable -> (cfg.autoLogin.enable && cfg.autoLogin.timeout == 0);
|
||||||
|
message = ''
|
||||||
|
LightDM can only run without greeter if automatic login is enabled and the timeout for it
|
||||||
|
is set to zero.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
services.xserver.displayManager.slim.enable = false;
|
services.xserver.displayManager.slim.enable = false;
|
||||||
|
|
||||||
services.xserver.displayManager.job = {
|
services.xserver.displayManager.job = {
|
||||||
|
@ -144,6 +225,17 @@ in
|
||||||
session optional ${pkgs.systemd}/lib/security/pam_systemd.so
|
session optional ${pkgs.systemd}/lib/security/pam_systemd.so
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
security.pam.services.lightdm-autologin.text = ''
|
||||||
|
auth requisite pam_nologin.so
|
||||||
|
auth required pam_succeed_if.so uid >= 1000 quiet
|
||||||
|
auth required pam_permit.so
|
||||||
|
|
||||||
|
account include lightdm
|
||||||
|
|
||||||
|
password include lightdm
|
||||||
|
|
||||||
|
session include lightdm
|
||||||
|
'';
|
||||||
|
|
||||||
users.extraUsers.lightdm = {
|
users.extraUsers.lightdm = {
|
||||||
createHome = true;
|
createHome = true;
|
||||||
|
|
Loading…
Reference in New Issue