2009-09-10 16:49:16 +01:00
|
|
|
|
# This module declares the options to define a *display manager*, the
|
2019-11-11 21:18:23 +00:00
|
|
|
|
# program responsible for handling X logins (such as LightDM, GDM, or SDDM).
|
|
|
|
|
# The display manager allows the user to select a *session
|
|
|
|
|
# type*. When the user logs in, the display manager starts the
|
2009-09-10 16:49:16 +01:00
|
|
|
|
# *session script* ("xsession" below) to launch the selected session
|
2019-11-11 21:18:23 +00:00
|
|
|
|
# type. The session type defines two things: the *desktop manager*
|
2009-09-10 16:49:16 +01:00
|
|
|
|
# (e.g., KDE, Gnome or a plain xterm), and optionally the *window
|
|
|
|
|
# manager* (e.g. kwin or twm).
|
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
|
with lib;
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
|
|
|
|
let
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
|
cfg = config.services.xserver;
|
2009-09-10 13:37:33 +01:00
|
|
|
|
xorg = pkgs.xorg;
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
2014-11-30 19:49:19 +00:00
|
|
|
|
fontconfig = config.fonts.fontconfig;
|
|
|
|
|
xresourcesXft = pkgs.writeText "Xresources-Xft" ''
|
2015-02-01 22:18:48 +00:00
|
|
|
|
${optionalString (fontconfig.dpi != 0) ''Xft.dpi: ${toString fontconfig.dpi}''}
|
2014-11-30 19:49:19 +00:00
|
|
|
|
Xft.antialias: ${if fontconfig.antialias then "1" else "0"}
|
|
|
|
|
Xft.rgba: ${fontconfig.subpixel.rgba}
|
|
|
|
|
Xft.lcdfilter: lcd${fontconfig.subpixel.lcdfilter}
|
|
|
|
|
Xft.hinting: ${if fontconfig.hinting.enable then "1" else "0"}
|
|
|
|
|
Xft.autohint: ${if fontconfig.hinting.autohint then "1" else "0"}
|
freetype: 2.6.5 -> 2.7.1
The Infinality bytecode interpreter is removed in favor of the new v40 TrueType
interpreter. In the past, the Infinality interpreter provided support for
ClearType-style hinting instructions while the default interpreter (then v35)
provided support only for original TrueType-style instructions. The v40
interpreter corrects this deficiency, so the Infinality interpreter is no longer
necessary.
To understand why the Infinality interpreter is no longer necessary, we should
understand how ClearType differs from TrueType and how the v40 interpreter
works. The following is a summary of information available on the FreeType
website [1] mixed with my own editorializing.
TrueType instructions use horizontal and vertical hints to improve glyph
rendering. Before TrueType, fonts were only vertically hinted; horizontal hints
improved rendering by snapping stems to pixel boundaries. Horizontal hinting is
a risk because it can significantly distort glyph shapes and kerning. Extensive
testing at different resolutions is needed to perfect the TrueType
hints. Microsoft invested significant effort to do this with its "Core fonts for
the Web" project, but few other typefaces have seen this level of attention.
With the advent of subpixel rendering, the effective horizontal resolution of
most displays increased significantly. ClearType eschews horizontal hinting in
favor of horizontal supersampling. Most fonts are designed for the Microsoft
bytecode interpreter, which implements a compatibility mode with
TrueType-style (horizontal and vertical) instructions. However, applying the
full horizontal hints to subpixel-rendered fonts leads to color fringes and
inconsistent stem widths. The Infinality interpreter implements several
techniques to mitigate these problems, going so far as to embed font- and
glyph-specific hacks in the interpreter. On the other hand, the v40 interpreter
ignores the horizontal hinting instructions so that glyphs render as they are
intended to on the Microsoft interpreter. Without the horizontal hints, the
problems of glyph and kerning distortion, color fringes, and inconsistent stem
widths--the problems the Infinality interpreter was created to solve--simply
don't occur in the first place.
There are also security concerns which motivate removing the Infinality patches.
Although there is an updated version of the Infinality interpreter for FreeType
2.7, the lack of a consistent upstream maintainer is a security concern. The
interpreter is a Turing-complete virtual machine which has had security
vulnerabilities in the past. While the default interpreter is used in billions
of devices and is maintained by an active developer, the Infinality interpreter
is neither scrutinized nor maintained. We will probably never know if there are
defects in the Infinality interpreter, and if they were discovered they would
likely never be fixed. I do not think that is an acceptable situtation for a
core library like FreeType.
Dropping the Infinality patches means that font rendering will be less
customizable. I think this is an acceptable trade-off. The Infinality
interpreter made many compromises to mitigate the problems with horizontal
hinting; the main purpose of customization is to tailor these compromises to the
user's preferences. The new interpreter does not have to make these compromises
because it renders fonts as their designers intended, so this level of
customization is not necessary.
The Infinality-associated patches are also removed from cairo. These patches
only set the default rendering options in case they aren't set though
Fontconfig. On NixOS, the rendering options are always set in Fontconfig, so
these patches never actually did anything for us!
The Fontconfig test suite is patched to account for a quirk in the way PCF fonts
are named.
The fontconfig option `hintstyle` is no longer configurable in NixOS. This
option selects the TrueType interpreter; the v40 interpreter is `hintslight` and
the older v35 interpreter is `hintmedium` or `hintfull` (which have actually
always been the same thing). The setting may still be changed through the
`localConf` option or by creating a user Fontconfig file.
Users with HiDPI displays should probably disable hinting and antialiasing: at
best they have no visible effect.
The fontconfig-ultimate settings are still available in NixOS, but they are no
longer the default. They still work, but their main purpose is to set rendering
quirks which are no longer necessary and may actually be
detrimental (e.g. setting `hintfull` for some fonts). Also, the vast array of
font substitutions provided is not an appropriate default; the default setting
should be to give the user the font they asked for.
[1]. https://www.freetype.org/freetype2/docs/subpixel-hinting.html
2017-03-05 23:39:38 +00:00
|
|
|
|
Xft.hintstyle: hintslight
|
2014-11-30 19:49:19 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2019-12-10 14:10:30 +00:00
|
|
|
|
# file provided by services.xserver.displayManager.sessionData.wrapper
|
2018-07-24 15:52:49 +01:00
|
|
|
|
xsessionWrapper = pkgs.writeScript "xsession-wrapper"
|
2009-09-10 16:49:16 +01:00
|
|
|
|
''
|
2015-11-29 00:18:59 +00:00
|
|
|
|
#! ${pkgs.bash}/bin/bash
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2018-07-24 15:52:49 +01:00
|
|
|
|
# Shared environment setup for graphical sessions.
|
2017-02-12 23:09:24 +00:00
|
|
|
|
|
2012-11-05 22:07:53 +00:00
|
|
|
|
. /etc/profile
|
2011-08-12 11:04:43 +01:00
|
|
|
|
cd "$HOME"
|
|
|
|
|
|
2020-08-09 22:16:37 +01:00
|
|
|
|
# Allow the user to execute commands at the beginning of the X session.
|
|
|
|
|
if test -f ~/.xprofile; then
|
|
|
|
|
source ~/.xprofile
|
|
|
|
|
fi
|
|
|
|
|
|
2017-09-14 23:08:16 +01:00
|
|
|
|
${optionalString cfg.displayManager.job.logToJournal ''
|
|
|
|
|
if [ -z "$_DID_SYSTEMD_CAT" ]; then
|
|
|
|
|
export _DID_SYSTEMD_CAT=1
|
2018-07-24 15:52:49 +01:00
|
|
|
|
exec ${config.systemd.package}/bin/systemd-cat -t xsession "$0" "$@"
|
2017-09-14 23:08:16 +01:00
|
|
|
|
fi
|
|
|
|
|
''}
|
|
|
|
|
|
|
|
|
|
${optionalString cfg.displayManager.job.logToFile ''
|
|
|
|
|
exec &> >(tee ~/.xsession-errors)
|
|
|
|
|
''}
|
|
|
|
|
|
2018-08-04 14:38:01 +01:00
|
|
|
|
# Load X defaults. This should probably be safe on wayland too.
|
2014-11-30 19:49:19 +00:00
|
|
|
|
${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
|
2014-11-07 20:21:21 +00:00
|
|
|
|
if test -e ~/.Xresources; then
|
|
|
|
|
${xorg.xrdb}/bin/xrdb -merge ~/.Xresources
|
|
|
|
|
elif test -e ~/.Xdefaults; then
|
2009-09-13 14:34:52 +01:00
|
|
|
|
${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
|
2009-09-10 16:49:16 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2020-07-24 12:41:24 +01:00
|
|
|
|
# Import environment variables into the systemd user environment.
|
|
|
|
|
${optionalString (cfg.displayManager.importedVariables != []) (
|
|
|
|
|
"/run/current-system/systemd/bin/systemctl --user import-environment "
|
|
|
|
|
+ toString (unique cfg.displayManager.importedVariables)
|
|
|
|
|
)}
|
|
|
|
|
|
2013-08-26 15:04:42 +01:00
|
|
|
|
# Speed up application start by 50-150ms according to
|
|
|
|
|
# http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
|
2020-08-09 22:17:09 +01:00
|
|
|
|
compose_cache="''${XCOMPOSECACHE:-$HOME/.compose-cache}"
|
|
|
|
|
mkdir -p "$compose_cache"
|
2020-10-01 12:13:44 +01:00
|
|
|
|
# To avoid accidentally deleting a wrongly set up XCOMPOSECACHE directory,
|
|
|
|
|
# defensively try to delete cache *files* only, following the file format specified in
|
|
|
|
|
# https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/modules/im/ximcp/imLcIm.c#L353-358
|
|
|
|
|
# sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(), XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
|
|
|
|
|
${pkgs.findutils}/bin/find "$compose_cache" -maxdepth 1 -regextype posix-extended -regex '.*/[Bl][0-9]+_[0-9a-f]{3}_[0-9a-f]{8}_[0-9a-f]{8}' -delete
|
2020-08-09 22:17:09 +01:00
|
|
|
|
unset compose_cache
|
2013-08-26 15:04:42 +01:00
|
|
|
|
|
2015-09-28 14:14:44 +01:00
|
|
|
|
# Work around KDE errors when a user first logs in and
|
|
|
|
|
# .local/share doesn't exist yet.
|
2020-08-09 22:17:09 +01:00
|
|
|
|
mkdir -p "''${XDG_DATA_HOME:-$HOME/.local/share}"
|
2015-09-28 14:14:44 +01:00
|
|
|
|
|
2016-05-24 20:29:22 +01:00
|
|
|
|
unset _DID_SYSTEMD_CAT
|
|
|
|
|
|
2012-03-16 01:29:51 +00:00
|
|
|
|
${cfg.displayManager.sessionCommands}
|
|
|
|
|
|
2017-05-25 18:33:13 +01:00
|
|
|
|
# Start systemd user services for graphical sessions
|
2020-05-21 09:32:59 +01:00
|
|
|
|
/run/current-system/systemd/bin/systemctl --user start graphical-session.target
|
2017-05-25 18:33:13 +01:00
|
|
|
|
|
2009-09-13 14:34:52 +01:00
|
|
|
|
# Allow the user to setup a custom session type.
|
2009-10-15 09:27:51 +01:00
|
|
|
|
if test -x ~/.xsession; then
|
2019-06-15 04:22:35 +01:00
|
|
|
|
eval exec ~/.xsession "$@"
|
2018-07-24 15:52:49 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if test "$1"; then
|
|
|
|
|
# Run the supplied session command. Remove any double quotes with eval.
|
|
|
|
|
eval exec "$@"
|
2009-10-15 09:27:51 +01:00
|
|
|
|
else
|
2019-12-10 14:10:30 +00:00
|
|
|
|
# TODO: Do we need this? Should not the session always exist?
|
|
|
|
|
echo "error: unknown session $1" 1>&2
|
|
|
|
|
exit 1
|
2009-09-13 14:34:52 +01:00
|
|
|
|
fi
|
2018-07-24 15:52:49 +01:00
|
|
|
|
'';
|
|
|
|
|
|
2019-12-10 14:10:30 +00:00
|
|
|
|
installedSessions = pkgs.runCommand "desktops"
|
2015-09-01 08:42:08 +01:00
|
|
|
|
{ # trivial derivation
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
allowSubstitutes = false;
|
|
|
|
|
}
|
2009-09-10 16:49:16 +01:00
|
|
|
|
''
|
2019-12-10 14:10:30 +00:00
|
|
|
|
mkdir -p "$out/share/"{xsessions,wayland-sessions}
|
2018-07-23 00:11:26 +01:00
|
|
|
|
|
|
|
|
|
${concatMapStrings (pkg: ''
|
2019-01-12 07:43:24 +00:00
|
|
|
|
for n in ${concatStringsSep " " pkg.providedSessions}; do
|
|
|
|
|
if ! test -f ${pkg}/share/wayland-sessions/$n.desktop -o \
|
|
|
|
|
-f ${pkg}/share/xsessions/$n.desktop; then
|
|
|
|
|
echo "Couldn't find provided session name, $n.desktop, in session package ${pkg.name}:"
|
|
|
|
|
echo " ${pkg}"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2019-01-03 06:38:36 +00:00
|
|
|
|
if test -d ${pkg}/share/xsessions; then
|
|
|
|
|
${xorg.lndir}/bin/lndir ${pkg}/share/xsessions $out/share/xsessions
|
|
|
|
|
fi
|
2018-12-22 03:19:40 +00:00
|
|
|
|
if test -d ${pkg}/share/wayland-sessions; then
|
|
|
|
|
${xorg.lndir}/bin/lndir ${pkg}/share/wayland-sessions $out/share/wayland-sessions
|
|
|
|
|
fi
|
2019-01-12 07:00:31 +00:00
|
|
|
|
'') cfg.displayManager.sessionPackages}
|
2009-09-10 16:49:16 +01:00
|
|
|
|
'';
|
2009-04-13 11:57:36 +01:00
|
|
|
|
|
2019-12-10 14:10:30 +00:00
|
|
|
|
dmDefault = cfg.desktopManager.default;
|
2020-02-06 01:17:09 +00:00
|
|
|
|
# fallback default for cases when only default wm is set
|
|
|
|
|
dmFallbackDefault = if dmDefault != null then dmDefault else "none";
|
2019-12-10 14:10:30 +00:00
|
|
|
|
wmDefault = cfg.windowManager.default;
|
|
|
|
|
|
2020-02-06 01:17:09 +00:00
|
|
|
|
defaultSessionFromLegacyOptions = dmFallbackDefault + optionalString (wmDefault != null && wmDefault != "none") "+${wmDefault}";
|
2019-12-10 14:10:30 +00:00
|
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
2009-09-10 16:49:16 +01:00
|
|
|
|
options = {
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
2009-09-10 16:49:16 +01:00
|
|
|
|
services.xserver.displayManager = {
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
2009-09-10 16:49:16 +01:00
|
|
|
|
xauthBin = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
internal = true;
|
2009-09-10 16:49:16 +01:00
|
|
|
|
default = "${xorg.xauth}/bin/xauth";
|
|
|
|
|
description = "Path to the <command>xauth</command> program used by display managers.";
|
|
|
|
|
};
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
2009-09-10 16:49:16 +01:00
|
|
|
|
xserverBin = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.path;
|
2009-09-10 16:49:16 +01:00
|
|
|
|
description = "Path to the X server used by display managers.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
xserverArgs = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.listOf types.str;
|
2009-09-10 16:49:16 +01:00
|
|
|
|
default = [];
|
2014-12-22 20:00:32 +00:00
|
|
|
|
example = [ "-ac" "-logverbose" "-verbose" "-nolisten tcp" ];
|
2009-09-10 16:49:16 +01:00
|
|
|
|
description = "List of arguments for the X server.";
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-30 08:33:45 +01:00
|
|
|
|
setupCommands = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
|
|
|
|
description = ''
|
|
|
|
|
Shell commands executed just after the X server has started.
|
|
|
|
|
|
|
|
|
|
This option is only effective for display managers for which this feature
|
|
|
|
|
is supported; currently these are LightDM, GDM and SDDM.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2012-03-16 01:29:51 +00:00
|
|
|
|
sessionCommands = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.lines;
|
2012-03-16 01:29:51 +00:00
|
|
|
|
default = "";
|
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
xmessage "Hello World!" &
|
|
|
|
|
'';
|
2018-08-06 12:45:42 +01:00
|
|
|
|
description = ''
|
|
|
|
|
Shell commands executed just before the window or desktop manager is
|
|
|
|
|
started. These commands are not currently sourced for Wayland sessions.
|
|
|
|
|
'';
|
2012-03-16 01:29:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-03-10 01:04:40 +00:00
|
|
|
|
hiddenUsers = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ "nobody" ];
|
|
|
|
|
description = ''
|
|
|
|
|
A list of users which will not be shown in the display manager.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-12 07:00:31 +00:00
|
|
|
|
sessionPackages = mkOption {
|
2019-01-12 07:33:05 +00:00
|
|
|
|
type = with types; listOf (package // {
|
|
|
|
|
description = "package with provided sessions";
|
|
|
|
|
check = p: assertMsg
|
|
|
|
|
(package.check p && p ? providedSessions
|
|
|
|
|
&& p.providedSessions != [] && all isString p.providedSessions)
|
|
|
|
|
''
|
|
|
|
|
Package, '${p.name}', did not specify any session names, as strings, in
|
|
|
|
|
'passthru.providedSessions'. This is required when used as a session package.
|
|
|
|
|
|
|
|
|
|
The session names can be looked up in:
|
|
|
|
|
${p}/share/xsessions
|
|
|
|
|
${p}/share/wayland-sessions
|
|
|
|
|
'';
|
|
|
|
|
});
|
2018-07-23 00:11:26 +01:00
|
|
|
|
default = [];
|
|
|
|
|
description = ''
|
2019-01-12 07:00:31 +00:00
|
|
|
|
A list of packages containing x11 or wayland session files to be passed to the display manager.
|
2018-07-23 00:11:26 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 16:49:16 +01:00
|
|
|
|
session = mkOption {
|
|
|
|
|
default = [];
|
2013-10-30 15:19:07 +00:00
|
|
|
|
example = literalExample
|
|
|
|
|
''
|
|
|
|
|
[ { manage = "desktop";
|
|
|
|
|
name = "xterm";
|
|
|
|
|
start = '''
|
|
|
|
|
''${pkgs.xterm}/bin/xterm -ls &
|
|
|
|
|
waitPID=$!
|
|
|
|
|
''';
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
'';
|
2009-09-10 16:49:16 +01:00
|
|
|
|
description = ''
|
|
|
|
|
List of sessions supported with the command used to start each
|
|
|
|
|
session. Each session script can set the
|
|
|
|
|
<varname>waitPID</varname> shell variable to make this script
|
|
|
|
|
wait until the end of the user session. Each script is used
|
2018-09-17 11:58:15 +01:00
|
|
|
|
to define either a window manager or a desktop manager. These
|
2009-09-10 16:49:16 +01:00
|
|
|
|
can be differentiated by setting the attribute
|
|
|
|
|
<varname>manage</varname> either to <literal>"window"</literal>
|
|
|
|
|
or <literal>"desktop"</literal>.
|
|
|
|
|
|
|
|
|
|
The list of desktop manager and window manager should appear
|
|
|
|
|
inside the display manager with the desktop manager name
|
|
|
|
|
followed by the window manager name.
|
|
|
|
|
'';
|
2019-12-10 14:10:30 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sessionData = mkOption {
|
|
|
|
|
description = "Data exported for display managers’ convenience";
|
|
|
|
|
internal = true;
|
|
|
|
|
default = {};
|
|
|
|
|
apply = val: {
|
2018-07-24 15:52:49 +01:00
|
|
|
|
wrapper = xsessionWrapper;
|
2019-12-10 14:10:30 +00:00
|
|
|
|
desktops = installedSessions;
|
|
|
|
|
sessionNames = concatMap (p: p.providedSessions) cfg.displayManager.sessionPackages;
|
|
|
|
|
# We do not want to force users to set defaultSession when they have only single DE.
|
|
|
|
|
autologinSession =
|
|
|
|
|
if cfg.displayManager.defaultSession != null then
|
|
|
|
|
cfg.displayManager.defaultSession
|
|
|
|
|
else if cfg.displayManager.sessionData.sessionNames != [] then
|
|
|
|
|
head cfg.displayManager.sessionData.sessionNames
|
|
|
|
|
else
|
|
|
|
|
null;
|
2009-01-25 15:49:08 +00:00
|
|
|
|
};
|
2009-09-10 16:49:16 +01:00
|
|
|
|
};
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
2019-01-12 09:31:37 +00:00
|
|
|
|
defaultSession = mkOption {
|
2019-12-10 14:10:30 +00:00
|
|
|
|
type = with types; nullOr str // {
|
2019-01-12 09:31:37 +00:00
|
|
|
|
description = "session name";
|
2019-12-10 14:10:30 +00:00
|
|
|
|
check = d:
|
|
|
|
|
assertMsg (d != null -> (str.check d && elem d cfg.displayManager.sessionData.sessionNames)) ''
|
2019-01-12 09:31:37 +00:00
|
|
|
|
Default graphical session, '${d}', not found.
|
|
|
|
|
Valid names for 'services.xserver.displayManager.defaultSession' are:
|
2019-12-10 14:10:30 +00:00
|
|
|
|
${concatStringsSep "\n " cfg.displayManager.sessionData.sessionNames}
|
2019-01-12 09:31:37 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
2019-12-10 14:10:30 +00:00
|
|
|
|
default =
|
|
|
|
|
if dmDefault != null || wmDefault != null then
|
|
|
|
|
defaultSessionFromLegacyOptions
|
|
|
|
|
else
|
|
|
|
|
null;
|
2019-01-12 09:31:37 +00:00
|
|
|
|
example = "gnome";
|
2019-12-10 14:10:30 +00:00
|
|
|
|
description = ''
|
|
|
|
|
Graphical session to pre-select in the session chooser (only effective for GDM and LightDM).
|
|
|
|
|
|
|
|
|
|
On GDM, LightDM and SDDM, it will also be used as a session for auto-login.
|
|
|
|
|
'';
|
2019-01-12 09:31:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-07-24 12:41:24 +01:00
|
|
|
|
importedVariables = mkOption {
|
|
|
|
|
type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*");
|
|
|
|
|
visible = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Environment variables to import into the systemd user environment.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-10-15 16:22:30 +01:00
|
|
|
|
job = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2013-10-15 16:22:30 +01:00
|
|
|
|
preStart = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
|
|
|
|
example = "rm -f /var/log/my-display-manager.log";
|
|
|
|
|
description = "Script executed before the display manager is started.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
execCmd = mkOption {
|
2013-10-30 10:02:04 +00:00
|
|
|
|
type = types.str;
|
2014-08-27 22:41:15 +01:00
|
|
|
|
example = literalExample ''
|
2019-11-11 21:18:23 +00:00
|
|
|
|
"''${pkgs.lightdm}/bin/lightdm"
|
2014-08-27 22:41:15 +01:00
|
|
|
|
'';
|
2013-10-15 16:22:30 +01:00
|
|
|
|
description = "Command to start the display manager.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
environment = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
|
type = types.attrsOf types.unspecified;
|
2013-10-15 16:22:30 +01:00
|
|
|
|
default = {};
|
|
|
|
|
description = "Additional environment variables needed by the display manager.";
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-14 23:08:16 +01:00
|
|
|
|
logToFile = mkOption {
|
2013-10-15 16:22:30 +01:00
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
2017-09-14 23:08:16 +01:00
|
|
|
|
Whether the display manager redirects the output of the
|
|
|
|
|
session script to <filename>~/.xsession-errors</filename>.
|
2013-10-15 16:22:30 +01:00
|
|
|
|
'';
|
2009-09-10 16:49:16 +01:00
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2017-09-14 23:08:16 +01:00
|
|
|
|
logToJournal = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether the display manager redirects the output of the
|
|
|
|
|
session script to the systemd journal.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2016-05-24 20:29:22 +01:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-12 11:43:50 +01:00
|
|
|
|
# Configuration for automatic login. Common for all DM.
|
|
|
|
|
autoLogin = mkOption {
|
|
|
|
|
type = types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = cfg.displayManager.autoLogin.user != null;
|
|
|
|
|
description = ''
|
|
|
|
|
Automatically log in as <option>autoLogin.user</option>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
User to be used for the automatic login.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-08-07 14:43:58 +01:00
|
|
|
|
|
2020-04-12 11:43:50 +01:00
|
|
|
|
default = {};
|
|
|
|
|
description = ''
|
|
|
|
|
Auto login configuration attrset.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
|
};
|
2009-09-10 16:49:16 +01:00
|
|
|
|
|
2014-09-18 15:12:36 +01:00
|
|
|
|
config = {
|
2019-12-10 14:10:30 +00:00
|
|
|
|
assertions = [
|
2020-04-12 11:43:50 +01:00
|
|
|
|
{ assertion = cfg.displayManager.autoLogin.enable -> cfg.displayManager.autoLogin.user != null;
|
|
|
|
|
message = ''
|
|
|
|
|
services.xserver.displayManager.autoLogin.enable requires services.xserver.displayManager.autoLogin.user to be set
|
|
|
|
|
'';
|
|
|
|
|
}
|
2019-12-10 14:10:30 +00:00
|
|
|
|
{
|
|
|
|
|
assertion = cfg.desktopManager.default != null || cfg.windowManager.default != null -> cfg.displayManager.defaultSession == defaultSessionFromLegacyOptions;
|
|
|
|
|
message = "You cannot use both services.xserver.displayManager.defaultSession option and legacy options (services.xserver.desktopManager.default and services.xserver.windowManager.default).";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
warnings =
|
|
|
|
|
mkIf (dmDefault != null || wmDefault != null) [
|
|
|
|
|
''
|
|
|
|
|
The following options are deprecated:
|
|
|
|
|
${concatStringsSep "\n " (map ({c, t}: t) (filter ({c, t}: c != null) [
|
|
|
|
|
{ c = dmDefault; t = "- services.xserver.desktopManager.default"; }
|
|
|
|
|
{ c = wmDefault; t = "- services.xserver.windowManager.default"; }
|
|
|
|
|
]))}
|
|
|
|
|
Please use
|
2020-02-06 01:17:09 +00:00
|
|
|
|
services.xserver.displayManager.defaultSession = "${defaultSessionFromLegacyOptions}";
|
2019-12-10 14:10:30 +00:00
|
|
|
|
instead.
|
|
|
|
|
''
|
|
|
|
|
];
|
|
|
|
|
|
2015-10-17 23:53:13 +01:00
|
|
|
|
services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
|
2017-05-25 18:33:13 +01:00
|
|
|
|
|
2020-07-24 12:41:24 +01:00
|
|
|
|
services.xserver.displayManager.importedVariables = [
|
|
|
|
|
# This is required by user units using the session bus.
|
|
|
|
|
"DBUS_SESSION_BUS_ADDRESS"
|
|
|
|
|
# These are needed by the ssh-agent unit.
|
|
|
|
|
"DISPLAY"
|
|
|
|
|
"XAUTHORITY"
|
|
|
|
|
# This is required to specify session within user units (e.g. loginctl lock-session).
|
|
|
|
|
"XDG_SESSION_ID"
|
|
|
|
|
];
|
|
|
|
|
|
2017-05-25 18:33:13 +01:00
|
|
|
|
systemd.user.targets.graphical-session = {
|
|
|
|
|
unitConfig = {
|
|
|
|
|
RefuseManualStart = false;
|
|
|
|
|
StopWhenUnneeded = false;
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-12-10 14:10:30 +00:00
|
|
|
|
|
|
|
|
|
# Create desktop files and scripts for starting sessions for WMs/DMs
|
|
|
|
|
# that do not have upstream session files (those defined using services.{display,desktop,window}Manager.session options).
|
|
|
|
|
services.xserver.displayManager.sessionPackages =
|
|
|
|
|
let
|
|
|
|
|
dms = filter (s: s.manage == "desktop") cfg.displayManager.session;
|
|
|
|
|
wms = filter (s: s.manage == "window") cfg.displayManager.session;
|
|
|
|
|
|
|
|
|
|
# Script responsible for starting the window manager and the desktop manager.
|
2019-12-29 01:02:24 +00:00
|
|
|
|
xsession = dm: wm: pkgs.writeScript "xsession" ''
|
2019-12-10 14:10:30 +00:00
|
|
|
|
#! ${pkgs.bash}/bin/bash
|
|
|
|
|
|
|
|
|
|
# Legacy session script used to construct .desktop files from
|
|
|
|
|
# `services.xserver.displayManager.session` entries. Called from
|
|
|
|
|
# `sessionWrapper`.
|
|
|
|
|
|
|
|
|
|
# Start the window manager.
|
|
|
|
|
${wm.start}
|
|
|
|
|
|
|
|
|
|
# Start the desktop manager.
|
|
|
|
|
${dm.start}
|
|
|
|
|
|
|
|
|
|
${optionalString cfg.updateDbusEnvironment ''
|
|
|
|
|
${lib.getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all
|
|
|
|
|
''}
|
|
|
|
|
|
|
|
|
|
test -n "$waitPID" && wait "$waitPID"
|
|
|
|
|
|
2020-05-21 09:32:59 +01:00
|
|
|
|
/run/current-system/systemd/bin/systemctl --user stop graphical-session.target
|
2019-12-10 14:10:30 +00:00
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
'';
|
|
|
|
|
in
|
|
|
|
|
# We will generate every possible pair of WM and DM.
|
|
|
|
|
concatLists (
|
2021-01-28 22:03:02 +00:00
|
|
|
|
builtins.map
|
|
|
|
|
({dm, wm}: let
|
2019-12-10 14:10:30 +00:00
|
|
|
|
sessionName = "${dm.name}${optionalString (wm.name != "none") ("+" + wm.name)}";
|
|
|
|
|
script = xsession dm wm;
|
2020-03-28 13:51:12 +00:00
|
|
|
|
desktopNames = if dm ? desktopNames
|
|
|
|
|
then concatStringsSep ";" dm.desktopNames
|
|
|
|
|
else sessionName;
|
2019-12-10 14:10:30 +00:00
|
|
|
|
in
|
|
|
|
|
optional (dm.name != "none" || wm.name != "none")
|
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
|
name = "${sessionName}-xsession";
|
|
|
|
|
destination = "/share/xsessions/${sessionName}.desktop";
|
|
|
|
|
# Desktop Entry Specification:
|
|
|
|
|
# - https://standards.freedesktop.org/desktop-entry-spec/latest/
|
|
|
|
|
# - https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
|
|
|
|
|
text = ''
|
|
|
|
|
[Desktop Entry]
|
|
|
|
|
Version=1.0
|
|
|
|
|
Type=XSession
|
|
|
|
|
TryExec=${script}
|
|
|
|
|
Exec=${script}
|
|
|
|
|
Name=${sessionName}
|
2020-03-28 13:51:12 +00:00
|
|
|
|
DesktopNames=${desktopNames}
|
2019-12-10 14:10:30 +00:00
|
|
|
|
'';
|
|
|
|
|
} // {
|
|
|
|
|
providedSessions = [ sessionName ];
|
|
|
|
|
})
|
|
|
|
|
)
|
2021-01-28 22:03:02 +00:00
|
|
|
|
(cartesianProductOfSets { dm = dms; wm = wms; })
|
2019-12-10 14:10:30 +00:00
|
|
|
|
);
|
2020-10-21 19:38:37 +01:00
|
|
|
|
|
|
|
|
|
# Make xsessions and wayland sessions available in XDG_DATA_DIRS
|
|
|
|
|
# as some programs have behavior that depends on them being present
|
|
|
|
|
environment.sessionVariables.XDG_DATA_DIRS = [
|
|
|
|
|
"${cfg.displayManager.sessionData.desktops}/share"
|
|
|
|
|
];
|
2014-09-18 15:12:36 +01:00
|
|
|
|
};
|
|
|
|
|
|
2016-02-28 09:35:43 +00:00
|
|
|
|
imports = [
|
2019-12-10 01:51:19 +00:00
|
|
|
|
(mkRemovedOptionModule [ "services" "xserver" "displayManager" "desktopManagerHandlesLidAndPower" ]
|
2016-03-26 23:01:43 +00:00
|
|
|
|
"The option is no longer necessary because all display managers have already delegated lid management to systemd.")
|
2019-12-10 01:51:19 +00:00
|
|
|
|
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "job" "logsXsession" ] [ "services" "xserver" "displayManager" "job" "logToFile" ])
|
|
|
|
|
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "logToJournal" ] [ "services" "xserver" "displayManager" "job" "logToJournal" ])
|
2019-12-10 14:10:30 +00:00
|
|
|
|
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "extraSessionFilesPackages" ] [ "services" "xserver" "displayManager" "sessionPackages" ])
|
2016-02-28 09:35:43 +00:00
|
|
|
|
];
|
|
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
|
}
|