2015-03-02 17:58:35 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
xcfg = config.services.xserver;
|
|
|
|
dmcfg = xcfg.displayManager;
|
|
|
|
cfg = dmcfg.sddm;
|
2019-08-13 21:52:01 +00:00
|
|
|
xEnv = config.systemd.services.display-manager.environment;
|
2015-03-02 17:58:35 +00:00
|
|
|
|
2017-05-17 14:21:11 +00:00
|
|
|
inherit (pkgs) sddm;
|
2015-12-11 12:58:04 +00:00
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
xserverWrapper = pkgs.writeScript "xserver-wrapper" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
|
2019-10-19 23:16:42 +00:00
|
|
|
exec systemd-cat -t xserver-wrapper ${dmcfg.xserverBin} ${toString dmcfg.xserverArgs} "$@"
|
2015-03-02 17:58:35 +00:00
|
|
|
'';
|
|
|
|
|
2015-12-12 17:31:26 +00:00
|
|
|
Xsetup = pkgs.writeScript "Xsetup" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${cfg.setupScript}
|
2018-06-30 07:33:45 +00:00
|
|
|
${dmcfg.setupCommands}
|
2015-12-12 17:31:26 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
Xstop = pkgs.writeScript "Xstop" ''
|
|
|
|
#!/bin/sh
|
|
|
|
${cfg.stopScript}
|
|
|
|
'';
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
cfgFile = pkgs.writeText "sddm.conf" ''
|
|
|
|
[General]
|
2020-05-21 08:33:22 +00:00
|
|
|
HaltCommand=/run/current-system/systemd/bin/systemctl poweroff
|
|
|
|
RebootCommand=/run/current-system/systemd/bin/systemctl reboot
|
2016-01-26 06:17:32 +00:00
|
|
|
${optionalString cfg.autoNumlock ''
|
|
|
|
Numlock=on
|
|
|
|
''}
|
2015-03-02 17:58:35 +00:00
|
|
|
|
|
|
|
[Theme]
|
|
|
|
Current=${cfg.theme}
|
2017-05-17 14:21:11 +00:00
|
|
|
ThemeDir=/run/current-system/sw/share/sddm/themes
|
|
|
|
FacesDir=/run/current-system/sw/share/sddm/faces
|
2015-03-02 17:58:35 +00:00
|
|
|
|
|
|
|
[Users]
|
|
|
|
MaximumUid=${toString config.ids.uids.nixbld}
|
2015-03-10 21:32:53 +00:00
|
|
|
HideUsers=${concatStringsSep "," dmcfg.hiddenUsers}
|
2015-04-01 20:57:06 +00:00
|
|
|
HideShells=/run/current-system/sw/bin/nologin
|
2015-03-02 17:58:35 +00:00
|
|
|
|
2016-09-16 08:13:45 +00:00
|
|
|
[X11]
|
2016-11-16 22:34:51 +00:00
|
|
|
MinimumVT=${toString (if xcfg.tty != null then xcfg.tty else 7)}
|
2015-03-02 17:58:35 +00:00
|
|
|
ServerPath=${xserverWrapper}
|
2015-10-17 22:53:13 +00:00
|
|
|
XephyrPath=${pkgs.xorg.xorgserver.out}/bin/Xephyr
|
2019-12-10 14:10:30 +00:00
|
|
|
SessionCommand=${dmcfg.sessionData.wrapper}
|
|
|
|
SessionDir=${dmcfg.sessionData.desktops}/share/xsessions
|
2015-03-02 17:58:35 +00:00
|
|
|
XauthPath=${pkgs.xorg.xauth}/bin/xauth
|
2015-12-12 17:31:26 +00:00
|
|
|
DisplayCommand=${Xsetup}
|
|
|
|
DisplayStopCommand=${Xstop}
|
2018-05-16 04:15:29 +00:00
|
|
|
EnableHidpi=${if cfg.enableHidpi then "true" else "false"}
|
|
|
|
|
|
|
|
[Wayland]
|
|
|
|
EnableHidpi=${if cfg.enableHidpi then "true" else "false"}
|
2019-12-10 14:10:30 +00:00
|
|
|
SessionDir=${dmcfg.sessionData.desktops}/share/wayland-sessions
|
2015-10-17 17:11:22 +00:00
|
|
|
|
2015-10-31 15:03:01 +00:00
|
|
|
${optionalString cfg.autoLogin.enable ''
|
|
|
|
[Autologin]
|
|
|
|
User=${cfg.autoLogin.user}
|
2019-12-10 14:10:30 +00:00
|
|
|
Session=${autoLoginSessionName}.desktop
|
2017-04-11 16:08:51 +00:00
|
|
|
Relogin=${boolToString cfg.autoLogin.relogin}
|
2015-10-31 15:03:01 +00:00
|
|
|
''}
|
|
|
|
|
2015-10-17 17:11:22 +00:00
|
|
|
${cfg.extraConfig}
|
2015-03-02 17:58:35 +00:00
|
|
|
'';
|
|
|
|
|
2019-12-10 14:10:30 +00:00
|
|
|
autoLoginSessionName = dmcfg.sessionData.autologinSession;
|
2015-10-31 15:03:01 +00:00
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
in
|
|
|
|
{
|
2019-12-10 01:51:19 +00:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ]
|
|
|
|
"Set the option `services.xserver.displayManager.sddm.package' instead.")
|
|
|
|
];
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.displayManager.sddm = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable sddm as the display manager.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-05-16 04:15:29 +00:00
|
|
|
enableHidpi = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to enable automatic HiDPI mode.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Versions up to 0.17 are broken so this only works from 0.18 onwards.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-10-17 17:11:22 +00:00
|
|
|
extraConfig = mkOption {
|
2016-10-23 17:33:41 +00:00
|
|
|
type = types.lines;
|
2015-10-17 17:11:22 +00:00
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
[Autologin]
|
|
|
|
User=john
|
|
|
|
Session=plasma.desktop
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra lines appended to the configuration of SDDM.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
theme = mkOption {
|
|
|
|
type = types.str;
|
2016-09-16 08:13:45 +00:00
|
|
|
default = "";
|
2015-03-02 17:58:35 +00:00
|
|
|
description = ''
|
|
|
|
Greeter theme to use.
|
|
|
|
'';
|
|
|
|
};
|
2015-10-31 15:03:01 +00:00
|
|
|
|
2016-01-26 06:17:32 +00:00
|
|
|
autoNumlock = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable numlock at login.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-12-12 17:31:26 +00:00
|
|
|
setupScript = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
# workaround for using NVIDIA Optimus without Bumblebee
|
|
|
|
xrandr --setprovideroutputsource modesetting NVIDIA-0
|
|
|
|
xrandr --auto
|
|
|
|
'';
|
|
|
|
description = ''
|
2018-06-30 07:33:45 +00:00
|
|
|
A script to execute when starting the display server. DEPRECATED, please
|
|
|
|
use <option>services.xserver.displayManager.setupCommands</option>.
|
2015-12-12 17:31:26 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
stopScript = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
A script to execute when stopping the display server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-10-31 15:03:01 +00:00
|
|
|
autoLogin = mkOption {
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Configuration for automatic login.
|
|
|
|
'';
|
|
|
|
|
|
|
|
type = types.submodule {
|
2015-12-12 17:33:39 +00:00
|
|
|
options = {
|
2015-10-31 15:03:01 +00:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2016-07-17 16:37:43 +00:00
|
|
|
Automatically log in as <option>autoLogin.user</option>.
|
2015-10-31 15:03:01 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
2016-07-17 16:37:43 +00:00
|
|
|
User to be used for the automatic login.
|
2015-10-31 15:03:01 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
relogin = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2016-07-17 16:37:43 +00: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 15:03:01 +00:00
|
|
|
'';
|
|
|
|
};
|
2015-12-12 17:33:39 +00:00
|
|
|
};
|
2015-10-31 15:03:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2015-10-31 15:03:01 +00:00
|
|
|
assertions = [
|
2019-05-02 16:19:59 +00:00
|
|
|
{ assertion = xcfg.enable;
|
|
|
|
message = ''
|
|
|
|
SDDM requires services.xserver.enable to be true
|
|
|
|
'';
|
|
|
|
}
|
2015-10-31 15:03:01 +00:00
|
|
|
{ assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null;
|
2015-12-12 17:33:39 +00:00
|
|
|
message = ''
|
|
|
|
SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set
|
|
|
|
'';
|
2015-10-31 15:03:01 +00:00
|
|
|
}
|
2019-12-10 14:10:30 +00:00
|
|
|
{ assertion = cfg.autoLogin.enable -> autoLoginSessionName != null;
|
2015-10-31 15:03:01 +00:00
|
|
|
message = ''
|
2019-12-10 14:10:30 +00:00
|
|
|
SDDM auto-login requires that services.xserver.displayManager.defaultSession is set.
|
2015-12-12 17:33:39 +00:00
|
|
|
'';
|
2015-10-31 15:03:01 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
services.xserver.displayManager.job = {
|
2017-05-17 14:21:11 +00:00
|
|
|
environment = {
|
2017-06-15 12:58:55 +00:00
|
|
|
# Load themes from system environment
|
|
|
|
QT_PLUGIN_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtPluginPrefix;
|
|
|
|
QML2_IMPORT_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtQmlPrefix;
|
2017-05-17 14:21:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
execCmd = "exec /run/current-system/sw/bin/sddm";
|
2015-03-02 17:58:35 +00: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
|
2019-08-19 14:05:10 +00:00
|
|
|
session required pam_env.so conffile=${config.system.build.pamEnvironment} readenv=0
|
2015-03-02 17:58:35 +00:00
|
|
|
session optional ${pkgs.systemd}/lib/security/pam_systemd.so
|
|
|
|
session optional pam_keyinit.so force revoke
|
|
|
|
session optional pam_permit.so
|
|
|
|
'';
|
2015-10-31 15:03:01 +00: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 17:58:35 +00:00
|
|
|
};
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.sddm = {
|
2015-03-02 17:58:35 +00:00
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/sddm";
|
|
|
|
group = "sddm";
|
|
|
|
uid = config.ids.uids.sddm;
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.etc."sddm.conf".source = cfgFile;
|
2019-05-02 16:19:59 +00:00
|
|
|
environment.pathsToLink = [
|
|
|
|
"/share/sddm"
|
2018-09-22 17:23:31 +00:00
|
|
|
];
|
2015-03-02 17:58:35 +00:00
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.sddm.gid = config.ids.gids.sddm;
|
2015-03-02 17:58:35 +00:00
|
|
|
|
2017-05-17 14:21:11 +00:00
|
|
|
environment.systemPackages = [ sddm ];
|
|
|
|
services.dbus.packages = [ sddm ];
|
2016-11-16 22:34:51 +00:00
|
|
|
|
|
|
|
# To enable user switching, allow sddm to allocate TTYs/displays dynamically.
|
|
|
|
services.xserver.tty = null;
|
|
|
|
services.xserver.display = null;
|
2018-07-09 06:51:05 +00:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
# Prior to Qt 5.9.2, there is a QML cache invalidation bug which sometimes
|
|
|
|
# strikes new Plasma 5 releases. If the QML cache is not invalidated, SDDM
|
|
|
|
# will segfault without explanation. We really tore our hair out for awhile
|
|
|
|
# before finding the bug:
|
|
|
|
# https://bugreports.qt.io/browse/QTBUG-62302
|
|
|
|
# We work around the problem by deleting the QML cache before startup.
|
|
|
|
# This was supposedly fixed in Qt 5.9.2 however it has been reported with
|
|
|
|
# 5.10 and 5.11 as well. The initial workaround was to delete the directory
|
|
|
|
# in the Xsetup script but that doesn't do anything.
|
|
|
|
# Instead we use tmpfiles.d to ensure it gets wiped.
|
|
|
|
# This causes a small but perceptible delay when SDDM starts.
|
|
|
|
"e ${config.users.users.sddm.home}/.cache - - - 0"
|
|
|
|
];
|
2015-03-02 17:58:35 +00:00
|
|
|
};
|
|
|
|
}
|