nixos/display-managers: move "generic" DM unit to its own option set
This is the first step towards deprecating it.
This commit is contained in:
@@ -611,6 +611,7 @@
|
||||
./services/display-managers/default.nix
|
||||
./services/display-managers/dms-greeter.nix
|
||||
./services/display-managers/gdm.nix
|
||||
./services/display-managers/generic.nix
|
||||
./services/display-managers/greetd.nix
|
||||
./services/display-managers/lemurs.nix
|
||||
./services/display-managers/ly.nix
|
||||
|
||||
@@ -40,26 +40,7 @@ in
|
||||
{
|
||||
options = {
|
||||
services.displayManager = {
|
||||
enable = lib.mkEnableOption "systemd's display-manager service";
|
||||
|
||||
preStart = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
example = "rm -f /var/log/my-display-manager.log";
|
||||
description = "Script executed before the display manager is started.";
|
||||
};
|
||||
|
||||
execCmd = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = lib.literalExpression ''"''${pkgs.lightdm}/bin/lightdm"'';
|
||||
description = "Command to start the display manager.";
|
||||
};
|
||||
|
||||
environment = lib.mkOption {
|
||||
type = with lib.types; attrsOf unspecified;
|
||||
default = { };
|
||||
description = "Additional environment variables needed by the display manager.";
|
||||
};
|
||||
enable = lib.mkEnableOption "shared display manager integration";
|
||||
|
||||
hiddenUsers = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
@@ -250,50 +231,5 @@ in
|
||||
else
|
||||
null;
|
||||
};
|
||||
|
||||
# so that the service won't be enabled when only startx is used
|
||||
systemd.services.display-manager.enable =
|
||||
let
|
||||
dmConf = config.services.xserver.displayManager;
|
||||
noDmUsed =
|
||||
!(
|
||||
cfg.gdm.enable
|
||||
|| cfg.sddm.enable
|
||||
|| dmConf.xpra.enable
|
||||
|| dmConf.lightdm.enable
|
||||
|| cfg.ly.enable
|
||||
|| cfg.lemurs.enable
|
||||
);
|
||||
in
|
||||
lib.mkIf noDmUsed (lib.mkDefault false);
|
||||
|
||||
systemd.services.display-manager = {
|
||||
description = "Display Manager";
|
||||
after = [
|
||||
"acpid.service"
|
||||
"systemd-logind.service"
|
||||
"systemd-user-sessions.service"
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
conflicts = [
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
restartIfChanged = false;
|
||||
|
||||
environment = cfg.environment;
|
||||
|
||||
preStart = cfg.preStart;
|
||||
script = lib.mkIf (config.systemd.services.display-manager.enable == true) cfg.execCmd;
|
||||
|
||||
# Stop restarting if the display manager stops (crashes) 2 times
|
||||
# in one minute. Starting X typically takes 3-4s.
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 3;
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = "200ms";
|
||||
SyslogIdentifier = "display-manager";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -217,27 +217,30 @@ in
|
||||
# Enable desktop session data
|
||||
enable = true;
|
||||
|
||||
environment = {
|
||||
GDM_X_SERVER_EXTRA_ARGS = toString (lib.filter (arg: arg != "-terminate") xdmcfg.xserverArgs);
|
||||
XDG_DATA_DIRS = lib.makeSearchPath "share" [
|
||||
gdm # for gnome-login.session
|
||||
config.services.displayManager.sessionData.desktops
|
||||
pkgs.gnome-control-center # for accessibility icon
|
||||
pkgs.adwaita-icon-theme
|
||||
pkgs.hicolor-icon-theme # empty icon theme as a base
|
||||
];
|
||||
}
|
||||
// lib.optionalAttrs (xSessionWrapper != null) {
|
||||
# Make GDM use this wrapper before running the session, which runs the
|
||||
# configured setupCommands. This relies on a patched GDM which supports
|
||||
# this environment variable.
|
||||
GDM_X_SESSION_WRAPPER = "${xSessionWrapper}";
|
||||
generic = {
|
||||
enable = true;
|
||||
environment = {
|
||||
GDM_X_SERVER_EXTRA_ARGS = toString (lib.filter (arg: arg != "-terminate") xdmcfg.xserverArgs);
|
||||
XDG_DATA_DIRS = lib.makeSearchPath "share" [
|
||||
gdm # for gnome-login.session
|
||||
config.services.displayManager.sessionData.desktops
|
||||
pkgs.gnome-control-center # for accessibility icon
|
||||
pkgs.adwaita-icon-theme
|
||||
pkgs.hicolor-icon-theme # empty icon theme as a base
|
||||
];
|
||||
}
|
||||
// lib.optionalAttrs (xSessionWrapper != null) {
|
||||
# Make GDM use this wrapper before running the session, which runs the
|
||||
# configured setupCommands. This relies on a patched GDM which supports
|
||||
# this environment variable.
|
||||
GDM_X_SESSION_WRAPPER = "${xSessionWrapper}";
|
||||
};
|
||||
execCmd = "exec ${gdm}/bin/gdm";
|
||||
preStart = lib.optionalString (defaultSessionName != null) ''
|
||||
# Set default session in session chooser to a specified values – basically ignore session history.
|
||||
${setSessionScript}/bin/set-session ${config.services.displayManager.sessionData.autologinSession}
|
||||
'';
|
||||
};
|
||||
execCmd = "exec ${gdm}/bin/gdm";
|
||||
preStart = lib.optionalString (defaultSessionName != null) ''
|
||||
# Set default session in session chooser to a specified values – basically ignore session history.
|
||||
${setSessionScript}/bin/set-session ${config.services.displayManager.sessionData.autologinSession}
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.services.displayManager.generic;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "displayManager" "preStart" ]
|
||||
[ "services" "displayManager" "generic" "preStart" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "displayManager" "execCmd" ]
|
||||
[ "services" "displayManager" "generic" "execCmd" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "displayManager" "environment" ]
|
||||
[ "services" "displayManager" "generic" "environment" ]
|
||||
)
|
||||
];
|
||||
|
||||
options = {
|
||||
services.displayManager.generic = {
|
||||
enable = lib.mkEnableOption "generic display manager integration - deprecated";
|
||||
|
||||
preStart = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
example = "rm -f /var/log/my-display-manager.log";
|
||||
description = "Script executed before the display manager is started.";
|
||||
};
|
||||
|
||||
execCmd = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
example = lib.literalExpression ''"''${pkgs.lightdm}/bin/lightdm"'';
|
||||
description = "Command to start the display manager.";
|
||||
};
|
||||
|
||||
environment = lib.mkOption {
|
||||
type = with lib.types; attrsOf unspecified;
|
||||
default = { };
|
||||
description = "Additional environment variables needed by the display manager.";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (cfg.enable || cfg.execCmd != null) {
|
||||
warnings = [
|
||||
(lib.mkIf (!cfg.enable) ''
|
||||
Enabling display-manager.service implicitly due to `services.displayManager.generic.execCmd` being set; this will be removed eventually.
|
||||
Please set `services.displayManager.generic.enable` explicitly, or switch your display manager to use upstream systemd units (preferred).
|
||||
'')
|
||||
];
|
||||
|
||||
systemd.services.display-manager = {
|
||||
description = "Display Manager";
|
||||
after = [
|
||||
"acpid.service"
|
||||
"systemd-logind.service"
|
||||
"systemd-user-sessions.service"
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
conflicts = [
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
restartIfChanged = false;
|
||||
|
||||
environment = cfg.environment;
|
||||
|
||||
preStart = cfg.preStart;
|
||||
script = cfg.execCmd;
|
||||
|
||||
# Stop restarting if the display manager stops (crashes) 2 times
|
||||
# in one minute. Starting X typically takes 3-4s.
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 3;
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = "200ms";
|
||||
SyslogIdentifier = "display-manager";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -76,7 +76,10 @@ in
|
||||
};
|
||||
displayManager = {
|
||||
enable = true;
|
||||
execCmd = "exec ${lib.getExe cfg.package} --config ${settingsFormat.generate "config.toml" cfg.settings}";
|
||||
generic = {
|
||||
enable = true;
|
||||
execCmd = "exec ${lib.getExe cfg.package} --config ${settingsFormat.generate "config.toml" cfg.settings}";
|
||||
};
|
||||
# set default settings
|
||||
lemurs.settings =
|
||||
let
|
||||
|
||||
@@ -107,7 +107,10 @@ in
|
||||
|
||||
displayManager = {
|
||||
enable = true;
|
||||
execCmd = "exec /run/current-system/sw/bin/ly";
|
||||
generic = {
|
||||
enable = true;
|
||||
execCmd = "exec /run/current-system/sw/bin/ly";
|
||||
};
|
||||
|
||||
# Set this here instead of 'defaultConfig' so users get eval
|
||||
# errors when they change it.
|
||||
|
||||
@@ -361,7 +361,10 @@ in
|
||||
|
||||
services.displayManager = {
|
||||
enable = true;
|
||||
execCmd = "exec /run/current-system/sw/bin/sddm";
|
||||
generic = {
|
||||
enable = true;
|
||||
execCmd = "exec /run/current-system/sw/bin/sddm";
|
||||
};
|
||||
};
|
||||
|
||||
security.pam.services = {
|
||||
|
||||
@@ -151,11 +151,9 @@ in
|
||||
# We can't just rely on 'Conflicts=autovt@tty1.service' because
|
||||
# 'switch-to-configuration switch' will start 'autovt@tty1.service'
|
||||
# and kill the display manager.
|
||||
systemd.targets.getty.wants =
|
||||
lib.mkIf (!(config.systemd.services.display-manager.enable or false))
|
||||
[
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
systemd.targets.getty.wants = lib.mkIf (!config.services.displayManager.enable) [
|
||||
"autovt@tty1.service"
|
||||
];
|
||||
|
||||
systemd.services."getty@" = {
|
||||
serviceConfig.ExecStart = [
|
||||
|
||||
@@ -215,22 +215,24 @@ in
|
||||
|
||||
# Set default session in session chooser to a specified values – basically ignore session history.
|
||||
# Auto-login is already covered by a config value.
|
||||
services.displayManager.preStart =
|
||||
services.displayManager.generic.preStart =
|
||||
optionalString (!dmcfg.autoLogin.enable && dmcfg.defaultSession != null)
|
||||
''
|
||||
${setSessionScript}/bin/set-session ${dmcfg.defaultSession}
|
||||
'';
|
||||
|
||||
# setSessionScript needs session-files in XDG_DATA_DIRS
|
||||
services.displayManager.environment.XDG_DATA_DIRS = "${dmcfg.sessionData.desktops}/share/";
|
||||
services.displayManager.generic.environment.XDG_DATA_DIRS = "${dmcfg.sessionData.desktops}/share/";
|
||||
|
||||
# setSessionScript wants AccountsService
|
||||
systemd.services.display-manager.wants = [
|
||||
"accounts-daemon.service"
|
||||
];
|
||||
|
||||
services.displayManager.generic.enable = true;
|
||||
|
||||
# lightdm relaunches itself via just `lightdm`, so needs to be on the PATH
|
||||
services.displayManager.execCmd = ''
|
||||
services.displayManager.generic.execCmd = ''
|
||||
export PATH=${lightdm}/sbin:$PATH
|
||||
exec ${lightdm}/sbin/lightdm
|
||||
'';
|
||||
|
||||
@@ -300,7 +300,8 @@ in
|
||||
VideoRam 192000
|
||||
'';
|
||||
|
||||
services.displayManager.execCmd = ''
|
||||
services.displayManager.generic.enable = true;
|
||||
services.displayManager.generic.execCmd = ''
|
||||
${optionalString (cfg.pulseaudio) "export PULSE_COOKIE=/run/pulse/.config/pulse/cookie"}
|
||||
exec ${pkgs.xpra}/bin/xpra ${
|
||||
if cfg.desktop == null then "start" else "start-desktop --start=${cfg.desktop}"
|
||||
|
||||
@@ -849,35 +849,10 @@ in
|
||||
|
||||
environment.pathsToLink = [ "/share/X11" ];
|
||||
|
||||
systemd.services.display-manager = {
|
||||
description = "Display Manager";
|
||||
|
||||
after = [
|
||||
"acpid.service"
|
||||
"systemd-logind.service"
|
||||
"systemd-user-sessions.service"
|
||||
];
|
||||
|
||||
restartIfChanged = false;
|
||||
|
||||
environment = config.services.displayManager.environment;
|
||||
|
||||
preStart = ''
|
||||
${config.services.displayManager.preStart}
|
||||
|
||||
rm -f /tmp/.X0-lock
|
||||
'';
|
||||
|
||||
# Stop restarting if the display manager stops (crashes) 2 times
|
||||
# in one minute. Starting X typically takes 3-4s.
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 3;
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = "200ms";
|
||||
SyslogIdentifier = "display-manager";
|
||||
};
|
||||
};
|
||||
# FIXME: what
|
||||
services.displayManager.generic.preStart = ''
|
||||
rm -f /tmp/.X0-lock
|
||||
'';
|
||||
|
||||
services.xserver.displayManager.xserverArgs = [
|
||||
"-config ${configFile}"
|
||||
|
||||
Reference in New Issue
Block a user