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
|
|
|
|
2020-12-16 13:33:40 +00:00
|
|
|
sddm = pkgs.libsForQt5.sddm;
|
2015-12-11 12:58:04 +00:00
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
iniFmt = pkgs.formats.ini { };
|
|
|
|
|
|
|
|
xserverWrapper = pkgs.writeShellScript "xserver-wrapper" ''
|
2015-03-02 17:58:35 +00:00
|
|
|
${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
|
|
|
'';
|
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
Xsetup = pkgs.writeShellScript "Xsetup" ''
|
2015-12-12 17:31:26 +00:00
|
|
|
${cfg.setupScript}
|
2018-06-30 07:33:45 +00:00
|
|
|
${dmcfg.setupCommands}
|
2015-12-12 17:31:26 +00:00
|
|
|
'';
|
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
Xstop = pkgs.writeShellScript "Xstop" ''
|
2015-12-12 17:31:26 +00:00
|
|
|
${cfg.stopScript}
|
|
|
|
'';
|
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
defaultConfig = {
|
|
|
|
General = {
|
|
|
|
HaltCommand = "/run/current-system/systemd/bin/systemctl poweroff";
|
|
|
|
RebootCommand = "/run/current-system/systemd/bin/systemctl reboot";
|
|
|
|
Numlock = if cfg.autoNumlock then "on" else "none"; # on, off none
|
2021-10-29 14:21:40 +00:00
|
|
|
|
|
|
|
# Implementation is done via pkgs/applications/display-managers/sddm/sddm-default-session.patch
|
|
|
|
DefaultSession = optionalString (dmcfg.defaultSession != null) "${dmcfg.defaultSession}.desktop";
|
2020-12-26 11:26:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Theme = {
|
|
|
|
Current = cfg.theme;
|
|
|
|
ThemeDir = "/run/current-system/sw/share/sddm/themes";
|
|
|
|
FacesDir = "/run/current-system/sw/share/sddm/faces";
|
|
|
|
};
|
|
|
|
|
|
|
|
Users = {
|
|
|
|
MaximumUid = config.ids.uids.nixbld;
|
|
|
|
HideUsers = concatStringsSep "," dmcfg.hiddenUsers;
|
|
|
|
HideShells = "/run/current-system/sw/bin/nologin";
|
|
|
|
};
|
2015-03-02 17:58:35 +00:00
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
X11 = {
|
|
|
|
MinimumVT = if xcfg.tty != null then xcfg.tty else 7;
|
|
|
|
ServerPath = toString xserverWrapper;
|
|
|
|
XephyrPath = "${pkgs.xorg.xorgserver.out}/bin/Xephyr";
|
|
|
|
SessionCommand = toString dmcfg.sessionData.wrapper;
|
|
|
|
SessionDir = "${dmcfg.sessionData.desktops}/share/xsessions";
|
|
|
|
XauthPath = "${pkgs.xorg.xauth}/bin/xauth";
|
|
|
|
DisplayCommand = toString Xsetup;
|
|
|
|
DisplayStopCommand = toString Xstop;
|
|
|
|
EnableHiDPI = cfg.enableHidpi;
|
|
|
|
};
|
|
|
|
|
|
|
|
Wayland = {
|
|
|
|
EnableHiDPI = cfg.enableHidpi;
|
|
|
|
SessionDir = "${dmcfg.sessionData.desktops}/share/wayland-sessions";
|
|
|
|
};
|
|
|
|
} // lib.optionalAttrs dmcfg.autoLogin.enable {
|
|
|
|
Autologin = {
|
|
|
|
User = dmcfg.autoLogin.user;
|
|
|
|
Session = autoLoginSessionName;
|
|
|
|
Relogin = cfg.autoLogin.relogin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
cfgFile =
|
|
|
|
iniFmt.generate "sddm.conf" (lib.recursiveUpdate defaultConfig cfg.settings);
|
|
|
|
|
|
|
|
autoLoginSessionName =
|
|
|
|
"${dmcfg.sessionData.autologinSession}.desktop";
|
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 = [
|
2020-12-26 11:26:30 +00:00
|
|
|
(mkRemovedOptionModule
|
|
|
|
[ "services" "xserver" "displayManager" "sddm" "themes" ]
|
2019-12-10 01:51:19 +00:00
|
|
|
"Set the option `services.xserver.displayManager.sddm.package' instead.")
|
2020-12-26 11:26:30 +00:00
|
|
|
(mkRenamedOptionModule
|
|
|
|
[ "services" "xserver" "displayManager" "sddm" "autoLogin" "enable" ]
|
|
|
|
[ "services" "xserver" "displayManager" "autoLogin" "enable" ])
|
|
|
|
(mkRenamedOptionModule
|
|
|
|
[ "services" "xserver" "displayManager" "sddm" "autoLogin" "user" ]
|
|
|
|
[ "services" "xserver" "displayManager" "autoLogin" "user" ])
|
|
|
|
(mkRemovedOptionModule
|
|
|
|
[ "services" "xserver" "displayManager" "sddm" "extraConfig" ]
|
|
|
|
"Set the option `services.xserver.displayManager.sddm.settings' instead.")
|
2019-12-10 01:51:19 +00:00
|
|
|
];
|
|
|
|
|
2015-03-02 17:58:35 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.displayManager.sddm = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to enable sddm as the display manager.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-05-16 04:15:29 +00:00
|
|
|
enableHidpi = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to enable automatic HiDPI mode.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-26 11:26:30 +00:00
|
|
|
settings = mkOption {
|
|
|
|
type = iniFmt.type;
|
|
|
|
default = { };
|
2021-10-03 16:06:03 +00:00
|
|
|
example = {
|
|
|
|
Autologin = {
|
|
|
|
User = "john";
|
|
|
|
Session = "plasma.desktop";
|
|
|
|
};
|
|
|
|
};
|
2015-10-17 17:11:22 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-12-18 00:31:14 +00:00
|
|
|
Extra settings merged in and overwriting defaults in sddm.conf.
|
2015-10-17 17:11:22 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
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 = lib.mdDoc ''
|
|
|
|
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 = lib.mdDoc ''
|
|
|
|
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 = lib.mdDoc ''
|
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`.
|
2015-12-12 17:31:26 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
stopScript = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
A script to execute when stopping the display server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-12 10:43:50 +00:00
|
|
|
# Configuration for automatic login specific to SDDM
|
2020-12-26 11:26:30 +00:00
|
|
|
autoLogin = {
|
|
|
|
relogin = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
minimumUid = mkOption {
|
|
|
|
type = types.ints.u16;
|
|
|
|
default = 1000;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Minimum user ID for auto-login user.
|
|
|
|
'';
|
|
|
|
};
|
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 = [
|
2020-12-26 11:26:30 +00:00
|
|
|
{
|
|
|
|
assertion = xcfg.enable;
|
2019-05-02 16:19:59 +00:00
|
|
|
message = ''
|
|
|
|
SDDM requires services.xserver.enable to be true
|
|
|
|
'';
|
|
|
|
}
|
2020-12-26 11:26:30 +00:00
|
|
|
{
|
|
|
|
assertion = dmcfg.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 = {
|
2023-02-21 21:48:03 +00:00
|
|
|
sddm.text = ''
|
|
|
|
auth substack login
|
|
|
|
account include login
|
|
|
|
password substack login
|
|
|
|
session include login
|
|
|
|
'';
|
2015-03-02 17:58:35 +00:00
|
|
|
|
|
|
|
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
|
2021-07-28 04:28:25 +00:00
|
|
|
session required pam_env.so conffile=/etc/pam/environment readenv=0
|
2022-05-05 11:23:32 +00:00
|
|
|
session optional ${config.systemd.package}/lib/security/pam_systemd.so
|
2015-03-02 17:58:35 +00:00
|
|
|
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
|
2020-12-26 11:26:30 +00:00
|
|
|
auth required pam_succeed_if.so uid >= ${toString cfg.autoLogin.minimumUid} quiet
|
2015-10-31 15:03:01 +00:00
|
|
|
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 ];
|
2023-08-23 12:52:50 +00:00
|
|
|
systemd.tmpfiles.packages = [ sddm ];
|
2016-11-16 22:34:51 +00:00
|
|
|
|
2023-06-23 14:41:57 +00:00
|
|
|
# We're not using the upstream unit, so copy these: https://github.com/sddm/sddm/blob/develop/services/sddm.service.in
|
|
|
|
systemd.services.display-manager.after = [
|
|
|
|
"systemd-user-sessions.service"
|
|
|
|
"getty@tty7.service"
|
|
|
|
"plymouth-quit.service"
|
|
|
|
"systemd-logind.service"
|
|
|
|
];
|
|
|
|
systemd.services.display-manager.conflicts = [
|
|
|
|
"getty@tty7.service"
|
|
|
|
];
|
|
|
|
|
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;
|
2015-03-02 17:58:35 +00:00
|
|
|
};
|
|
|
|
}
|