* Cleaned up the display manager module a bit.
svn path=/nixos/trunk/; revision=17012
This commit is contained in:
parent
22693ae44e
commit
0156cfbe9e
@ -1,183 +1,190 @@
|
|||||||
{pkgs, config, ...}:
|
# This module declares the options to define a *display manager*, the
|
||||||
|
# program responsible for handling X logins (such as xdm, kdm, gdb, or
|
||||||
|
# SLiM). The display manager allows the user to select a *session
|
||||||
|
# type*. When the user logs in, the display manager starts the
|
||||||
|
# *session script* ("xsession" below) to launch the selected session
|
||||||
|
# type. The session type defines two things: the *desktop manager*
|
||||||
|
# (e.g., KDE, Gnome or a plain xterm), and optionally the *window
|
||||||
|
# manager* (e.g. kwin or twm).
|
||||||
|
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs.lib) mkOption mergeOneOption optionals filter concatMap concatMapStrings;
|
|
||||||
cfg = config.services.xserver;
|
cfg = config.services.xserver;
|
||||||
xorg = pkgs.xorg;
|
xorg = pkgs.xorg;
|
||||||
|
|
||||||
# file provided by services.xserver.displayManager.session.script
|
# file provided by services.xserver.displayManager.session.script
|
||||||
xsession = wm: dm: pkgs.writeScript "xsession" ''
|
xsession = wm: dm: pkgs.writeScript "xsession"
|
||||||
#!/bin/sh
|
''
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
source /etc/profile
|
exec > $HOME/.xsession-errors 2>&1
|
||||||
|
|
||||||
exec > $HOME/.Xerrors 2>&1
|
source /etc/profile
|
||||||
|
|
||||||
|
### Load X defaults.
|
||||||
|
if test -e ~/.Xdefaults; then
|
||||||
|
${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
|
||||||
|
fi
|
||||||
|
|
||||||
### Load X defaults.
|
${optionalString cfg.startSSHAgent ''
|
||||||
if test -e ~/.Xdefaults; then
|
### Start the SSH agent.
|
||||||
${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
|
export SSH_ASKPASS=${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass
|
||||||
fi
|
eval $(${pkgs.openssh}/bin/ssh-agent)
|
||||||
|
''}
|
||||||
|
|
||||||
${if cfg.startSSHAgent then ''
|
### Allow user to override system-wide configuration
|
||||||
### Start the SSH agent.
|
if test -f ~/.xsession; then
|
||||||
export SSH_ASKPASS=${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass
|
source ~/.xsession
|
||||||
eval $(${pkgs.openssh}/bin/ssh-agent)
|
fi
|
||||||
'' else ""}
|
|
||||||
|
|
||||||
### Allow user to override system-wide configuration
|
# The first argument of this script is the session type
|
||||||
if test -f ~/.xsession; then
|
sessionType="$1"
|
||||||
source ~/.xsession;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# this script expect to have as first argument the following input
|
# The session type "<desktop-manager> + <window-manager>", so
|
||||||
# "desktop-manager + window-manager".
|
# extract those.
|
||||||
arg="$1"
|
windowManager="''${arg##* + }"
|
||||||
|
: ''${windowManager:=${cfg.windowManager.default}}
|
||||||
|
desktopManager="''${arg% + *}"
|
||||||
|
: ''${desktopManager:=${cfg.desktopManager.default}}
|
||||||
|
|
||||||
# extract the window manager.
|
# Start the window manager.
|
||||||
windowManager="''${arg##* + }"
|
case $windowManager in
|
||||||
: ''${windowManager:=${cfg.windowManager.default}}
|
${concatMapStrings (s: ''
|
||||||
# extract the desktop manager.
|
(${s.name})
|
||||||
desktopManager="''${arg% + *}"
|
${s.start}
|
||||||
: ''${desktopManager:=${cfg.desktopManager.default}}
|
;;
|
||||||
|
'') wm}
|
||||||
|
(*) echo "$0: Window manager '$windowManager' not found.";;
|
||||||
|
esac
|
||||||
|
|
||||||
# used to restart the xserver.
|
# Start the desktop manager.
|
||||||
waitPID=0
|
case $desktopManager in
|
||||||
|
${concatMapStrings (s: ''
|
||||||
|
(${s.name})
|
||||||
|
${s.start}
|
||||||
|
;;
|
||||||
|
'') dm}
|
||||||
|
(*) echo "$0: Desktop manager '$desktopManager' not found.";;
|
||||||
|
esac
|
||||||
|
|
||||||
# handle window manager starts.
|
test -n "$waitPID" && wait "$waitPID"
|
||||||
case $windowManager in
|
exit 0
|
||||||
${concatMapStrings (s: "
|
'';
|
||||||
(${s.name})
|
|
||||||
${s.start}
|
|
||||||
;;
|
|
||||||
") wm}
|
|
||||||
(*) echo "$0: Window manager '$windowManager' not found.";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# handle desktop manager starts.
|
mkDesktops = names: pkgs.runCommand "desktops" {}
|
||||||
case $desktopManager in
|
''
|
||||||
${concatMapStrings (s: "
|
ensureDir $out
|
||||||
(${s.name})
|
${concatMapStrings (n: ''
|
||||||
${s.start}
|
cat - > "$out/${n}.desktop" << EODESKTOP
|
||||||
;;
|
[Desktop Entry]
|
||||||
") dm}
|
Version=1.0
|
||||||
(*) echo "$0: Desktop manager '$desktopManager' not found.";;
|
Type=XSession
|
||||||
esac
|
TryExec=${cfg.displayManager.session.script}
|
||||||
|
Exec=${cfg.displayManager.session.script} '${n}'
|
||||||
test "$waitPID" != 0 && wait "$waitPID"
|
Name=${n}
|
||||||
exit
|
Comment=
|
||||||
'';
|
EODESKTOP
|
||||||
|
'') names}
|
||||||
mkDesktops = names: pkgs.runCommand "desktops" {} ''
|
'';
|
||||||
ensureDir $out
|
|
||||||
${concatMapStrings (n: ''
|
|
||||||
cat - > "$out/${n}.desktop" << EODESKTOP
|
|
||||||
[Desktop Entry]
|
|
||||||
Version=1.0
|
|
||||||
Type=XSession
|
|
||||||
TryExec=${cfg.displayManager.session.script}
|
|
||||||
Exec=${cfg.displayManager.session.script} '${n}'
|
|
||||||
Name=${n}
|
|
||||||
Comment=
|
|
||||||
EODESKTOP
|
|
||||||
'') names}
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
# list of display managers.
|
|
||||||
require = [
|
|
||||||
./kdm.nix
|
|
||||||
./slim.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
imports = [ ./kdm.nix ./slim.nix ];
|
||||||
xserver = {
|
|
||||||
displayManager = {
|
|
||||||
|
|
||||||
xauthBin = mkOption {
|
|
||||||
default = "${xorg.xauth}/bin/xauth";
|
options = {
|
||||||
description = "
|
|
||||||
Path to the xauth binary used by display managers.
|
services.xserver.displayManager = {
|
||||||
";
|
|
||||||
|
xauthBin = mkOption {
|
||||||
|
default = "${xorg.xauth}/bin/xauth";
|
||||||
|
description = "Path to the <command>xauth</command> program used by display managers.";
|
||||||
|
};
|
||||||
|
|
||||||
|
xserverBin = mkOption {
|
||||||
|
default = "${xorg.xorgserver}/bin/X";
|
||||||
|
description = "Path to the X server used by display managers.";
|
||||||
|
};
|
||||||
|
|
||||||
|
xserverArgs = mkOption {
|
||||||
|
default = [];
|
||||||
|
example = [ "-ac" "-logverbose" "-nolisten tcp" ];
|
||||||
|
description = "List of arguments for the X server.";
|
||||||
|
apply = toString;
|
||||||
|
};
|
||||||
|
|
||||||
|
session = mkOption {
|
||||||
|
default = [];
|
||||||
|
example = [
|
||||||
|
{
|
||||||
|
manage = "desktop";
|
||||||
|
name = "xterm";
|
||||||
|
start = "
|
||||||
|
${pkgs.xterm}/bin/xterm -ls &
|
||||||
|
waitPID=$!
|
||||||
|
";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
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
|
||||||
|
to define either a windows manager or a desktop manager. These
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
apply = list: rec {
|
||||||
|
wm = filter (s: s.manage == "window") list;
|
||||||
|
dm = filter (s: s.manage == "desktop") list;
|
||||||
|
names = concatMap (d: map (w: d.name + " + " + w.name) wm) dm;
|
||||||
|
desktops = mkDesktops names;
|
||||||
|
script = xsession wm dm;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
xserverBin = mkOption {
|
job = mkOption {
|
||||||
default = "${xorg.xorgserver}/bin/X";
|
default = {};
|
||||||
description = "
|
type = types.optionSet;
|
||||||
Path to the xserver binary used by display managers.
|
merge = mergeOneOption;
|
||||||
";
|
description = "This option defines how to start the display manager.";
|
||||||
};
|
|
||||||
|
|
||||||
xserverArgs = mkOption {
|
options = {
|
||||||
default = [];
|
|
||||||
example = [
|
|
||||||
"-ac"
|
|
||||||
"-logverbose"
|
|
||||||
"-nolisten tcp"
|
|
||||||
];
|
|
||||||
description = "
|
|
||||||
List of arguments which have to be pass to when
|
|
||||||
the display manager start the xserver.
|
|
||||||
";
|
|
||||||
apply = toString;
|
|
||||||
};
|
|
||||||
|
|
||||||
session = mkOption {
|
preStart = mkOption {
|
||||||
default = [];
|
default = "";
|
||||||
example = [
|
example = "rm -f /var/log/my-display-manager.log";
|
||||||
{
|
description = "Script executed before the display manager is started.";
|
||||||
manage = "desktop";
|
|
||||||
name = "xterm";
|
|
||||||
start = "
|
|
||||||
${pkgs.xterm}/bin/xterm -ls &
|
|
||||||
waitPID=$!
|
|
||||||
";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
description = ''
|
|
||||||
List of session supported with the command used to start each
|
|
||||||
session. Each session script can set the
|
|
||||||
<varname>waitPID</varname> shell variable to make this script
|
|
||||||
waiting until the end of the user session. Each script is used
|
|
||||||
to define either a windows manager or a desktop manager. These
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
apply = list: rec {
|
|
||||||
wm = filter (s: s.manage == "window") list;
|
|
||||||
dm = filter (s: s.manage == "desktop") list;
|
|
||||||
names = concatMap (d: map (w: d.name + " + " + w.name) wm) dm;
|
|
||||||
desktops = mkDesktops names;
|
|
||||||
script = xsession wm dm;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
job = mkOption {
|
|
||||||
default = {};
|
|
||||||
example = {
|
|
||||||
preStart = ''
|
|
||||||
rm -f /var/log/slim.log
|
|
||||||
'';
|
|
||||||
environment = { SLIM_CFGFILE = /etc/slim.conf; };
|
|
||||||
execCmd = "${pkgs.slim}/bin/slim";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
description = "
|
execCmd = mkOption {
|
||||||
List of arguments which have to be pass to when
|
example = "${pkgs.slim}/bin/slim";
|
||||||
the display manager start the xserver.
|
description = "Command to start the display manager.";
|
||||||
";
|
};
|
||||||
|
|
||||||
|
environment = mkOption {
|
||||||
|
default = {};
|
||||||
|
example = { SLIM_CFGFILE = /etc/slim.conf; };
|
||||||
|
description = "Additional environment variables needed by the display manager.";
|
||||||
|
};
|
||||||
|
|
||||||
merge = mergeOneOption;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,7 @@ in
|
|||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
services.xserver.displayManager.job =
|
services.xserver.displayManager.job =
|
||||||
{ beforeScript = "";
|
{ execCmd = "${kdebase_workspace}/bin/kdm -config ${kdmrc}";
|
||||||
environment = {};
|
|
||||||
execCmd = "${kdebase_workspace}/bin/kdm -config ${kdmrc}";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
security.pam.services = [ { name = "kde"; localLogin = true; ckHack = true; } ];
|
security.pam.services = [ { name = "kde"; localLogin = true; ckHack = true; } ];
|
||||||
|
@ -378,7 +378,7 @@ in
|
|||||||
else ""
|
else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
${cfg.displayManager.job.beforeScript}
|
${cfg.displayManager.job.preStart}
|
||||||
|
|
||||||
rm -f /tmp/.X0-lock
|
rm -f /tmp/.X0-lock
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user