2015-03-02 18:58:35 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
xcfg = config.services.xserver;
|
|
|
|
dmcfg = xcfg.displayManager;
|
|
|
|
cfg = dmcfg.sddm;
|
|
|
|
xEnv = config.systemd.services."display-manager".environment;
|
|
|
|
|
2017-05-17 16:21:11 +02:00
|
|
|
inherit (pkgs) sddm;
|
2015-12-11 13:58:04 +01:00
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
xserverWrapper = pkgs.writeScript "xserver-wrapper" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
|
2016-12-04 14:48:47 +01:00
|
|
|
exec systemd-cat ${dmcfg.xserverBin} ${toString dmcfg.xserverArgs} "$@"
|
2015-03-02 18:58:35 +01:00
|
|
|
'';
|
|
|
|
|
2015-12-12 18:31:26 +01:00
|
|
|
Xsetup = pkgs.writeScript "Xsetup" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${cfg.setupScript}
|
|
|
|
'';
|
|
|
|
|
|
|
|
Xstop = pkgs.writeScript "Xstop" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${cfg.stopScript}
|
|
|
|
'';
|
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
cfgFile = pkgs.writeText "sddm.conf" ''
|
|
|
|
[General]
|
|
|
|
HaltCommand=${pkgs.systemd}/bin/systemctl poweroff
|
|
|
|
RebootCommand=${pkgs.systemd}/bin/systemctl reboot
|
2016-01-26 07:17:32 +01:00
|
|
|
${optionalString cfg.autoNumlock ''
|
|
|
|
Numlock=on
|
|
|
|
''}
|
2015-03-02 18:58:35 +01:00
|
|
|
|
|
|
|
[Theme]
|
|
|
|
Current=${cfg.theme}
|
2017-05-17 16:21:11 +02:00
|
|
|
ThemeDir=/run/current-system/sw/share/sddm/themes
|
|
|
|
FacesDir=/run/current-system/sw/share/sddm/faces
|
2015-03-02 18:58:35 +01:00
|
|
|
|
|
|
|
[Users]
|
|
|
|
MaximumUid=${toString config.ids.uids.nixbld}
|
2015-03-10 22:32:53 +01:00
|
|
|
HideUsers=${concatStringsSep "," dmcfg.hiddenUsers}
|
2015-04-01 22:57:06 +02:00
|
|
|
HideShells=/run/current-system/sw/bin/nologin
|
2015-03-02 18:58:35 +01:00
|
|
|
|
2016-09-16 10:13:45 +02:00
|
|
|
[X11]
|
2016-11-16 23:34:51 +01:00
|
|
|
MinimumVT=${toString (if xcfg.tty != null then xcfg.tty else 7)}
|
2015-03-02 18:58:35 +01:00
|
|
|
ServerPath=${xserverWrapper}
|
2015-10-18 00:53:13 +02:00
|
|
|
XephyrPath=${pkgs.xorg.xorgserver.out}/bin/Xephyr
|
2015-03-02 18:58:35 +01:00
|
|
|
SessionCommand=${dmcfg.session.script}
|
|
|
|
SessionDir=${dmcfg.session.desktops}
|
|
|
|
XauthPath=${pkgs.xorg.xauth}/bin/xauth
|
2015-12-12 18:31:26 +01:00
|
|
|
DisplayCommand=${Xsetup}
|
|
|
|
DisplayStopCommand=${Xstop}
|
2015-10-17 19:11:22 +02:00
|
|
|
|
2015-10-31 16:03:01 +01:00
|
|
|
${optionalString cfg.autoLogin.enable ''
|
|
|
|
[Autologin]
|
|
|
|
User=${cfg.autoLogin.user}
|
|
|
|
Session=${defaultSessionName}.desktop
|
2017-04-11 18:08:51 +02:00
|
|
|
Relogin=${boolToString cfg.autoLogin.relogin}
|
2015-10-31 16:03:01 +01:00
|
|
|
''}
|
|
|
|
|
2015-10-17 19:11:22 +02:00
|
|
|
${cfg.extraConfig}
|
2015-03-02 18:58:35 +01:00
|
|
|
'';
|
|
|
|
|
2015-10-31 16:03:01 +01:00
|
|
|
defaultSessionName =
|
|
|
|
let
|
|
|
|
dm = xcfg.desktopManager.default;
|
|
|
|
wm = xcfg.windowManager.default;
|
2017-04-23 05:00:08 +02:00
|
|
|
in dm + optionalString (wm != "none") ("+" + wm);
|
2015-10-31 16:03:01 +01:00
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.displayManager.sddm = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable sddm as the display manager.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-10-17 19:11:22 +02:00
|
|
|
extraConfig = mkOption {
|
2016-10-23 19:33:41 +02:00
|
|
|
type = types.lines;
|
2015-10-17 19:11:22 +02:00
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
[Autologin]
|
|
|
|
User=john
|
|
|
|
Session=plasma.desktop
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra lines appended to the configuration of SDDM.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
theme = mkOption {
|
|
|
|
type = types.str;
|
2016-09-16 10:13:45 +02:00
|
|
|
default = "";
|
2015-03-02 18:58:35 +01:00
|
|
|
description = ''
|
|
|
|
Greeter theme to use.
|
|
|
|
'';
|
|
|
|
};
|
2015-10-31 16:03:01 +01:00
|
|
|
|
2016-01-26 07:17:32 +01:00
|
|
|
autoNumlock = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable numlock at login.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-12-12 18:31:26 +01:00
|
|
|
setupScript = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
# workaround for using NVIDIA Optimus without Bumblebee
|
|
|
|
xrandr --setprovideroutputsource modesetting NVIDIA-0
|
|
|
|
xrandr --auto
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
A script to execute when starting the display server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
stopScript = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
A script to execute when stopping the display server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-10-31 16:03:01 +01:00
|
|
|
autoLogin = mkOption {
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Configuration for automatic login.
|
|
|
|
'';
|
|
|
|
|
|
|
|
type = types.submodule {
|
2015-12-12 18:33:39 +01:00
|
|
|
options = {
|
2015-10-31 16:03:01 +01:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2016-07-17 18:37:43 +02:00
|
|
|
Automatically log in as <option>autoLogin.user</option>.
|
2015-10-31 16:03:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
2016-07-17 18:37:43 +02:00
|
|
|
User to be used for the automatic login.
|
2015-10-31 16:03:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
relogin = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2016-07-17 18:37:43 +02:00
|
|
|
If true automatic login will kick in again on session exit (logout), otherwise it
|
|
|
|
will only log in automatically when the display-manager is started.
|
2015-10-31 16:03:01 +01:00
|
|
|
'';
|
|
|
|
};
|
2015-12-12 18:33:39 +01:00
|
|
|
};
|
2015-10-31 16:03:01 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2015-10-31 16:03:01 +01:00
|
|
|
assertions = [
|
|
|
|
{ assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null;
|
2015-12-12 18:33:39 +01:00
|
|
|
message = ''
|
|
|
|
SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set
|
|
|
|
'';
|
2015-10-31 16:03:01 +01:00
|
|
|
}
|
|
|
|
{ assertion = cfg.autoLogin.enable -> elem defaultSessionName dmcfg.session.names;
|
|
|
|
message = ''
|
|
|
|
SDDM auto-login requires that services.xserver.desktopManager.default and
|
2015-12-12 18:33:39 +01:00
|
|
|
services.xserver.windowMananger.default are set to valid values. The current
|
|
|
|
default session: ${defaultSessionName} is not valid.
|
|
|
|
'';
|
2015-10-31 16:03:01 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2015-03-02 18:58:35 +01:00
|
|
|
services.xserver.displayManager.slim.enable = false;
|
|
|
|
|
|
|
|
services.xserver.displayManager.job = {
|
|
|
|
logsXsession = true;
|
|
|
|
|
2017-05-17 16:21:11 +02:00
|
|
|
environment = {
|
|
|
|
# Take themes system environment
|
|
|
|
NIX_PROFILES = "/run/current-system/sw";
|
|
|
|
XDG_DATA_DIRS = "/run/current-system/sw/share";
|
|
|
|
};
|
|
|
|
|
|
|
|
execCmd = "exec /run/current-system/sw/bin/sddm";
|
2015-03-02 18:58:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
security.pam.services = {
|
|
|
|
sddm = {
|
|
|
|
allowNullPassword = true;
|
|
|
|
startSession = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
sddm-greeter.text = ''
|
|
|
|
auth required pam_succeed_if.so audit quiet_success user = sddm
|
|
|
|
auth optional pam_permit.so
|
|
|
|
|
|
|
|
account required pam_succeed_if.so audit quiet_success user = sddm
|
|
|
|
account sufficient pam_unix.so
|
|
|
|
|
|
|
|
password required pam_deny.so
|
|
|
|
|
|
|
|
session required pam_succeed_if.so audit quiet_success user = sddm
|
|
|
|
session required pam_env.so envfile=${config.system.build.pamEnvironment}
|
|
|
|
session optional ${pkgs.systemd}/lib/security/pam_systemd.so
|
|
|
|
session optional pam_keyinit.so force revoke
|
|
|
|
session optional pam_permit.so
|
|
|
|
'';
|
2015-10-31 16:03:01 +01:00
|
|
|
|
|
|
|
sddm-autologin.text = ''
|
|
|
|
auth requisite pam_nologin.so
|
|
|
|
auth required pam_succeed_if.so uid >= 1000 quiet
|
|
|
|
auth required pam_permit.so
|
|
|
|
|
|
|
|
account include sddm
|
|
|
|
|
|
|
|
password include sddm
|
|
|
|
|
|
|
|
session include sddm
|
|
|
|
'';
|
2015-03-02 18:58:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users.extraUsers.sddm = {
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/sddm";
|
|
|
|
group = "sddm";
|
|
|
|
uid = config.ids.uids.sddm;
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.etc."sddm.conf".source = cfgFile;
|
|
|
|
|
|
|
|
users.extraGroups.sddm.gid = config.ids.gids.sddm;
|
|
|
|
|
2017-05-17 16:21:11 +02:00
|
|
|
environment.systemPackages = [ sddm ];
|
|
|
|
services.dbus.packages = [ sddm ];
|
2016-11-16 23:34:51 +01:00
|
|
|
|
|
|
|
# To enable user switching, allow sddm to allocate TTYs/displays dynamically.
|
|
|
|
services.xserver.tty = null;
|
|
|
|
services.xserver.display = null;
|
2015-03-02 18:58:35 +01:00
|
|
|
};
|
|
|
|
}
|