3
0
Fork 0
forked from mirrors/nixpkgs

lightdm & xserver service: add ability to spawn more than one X server

- if xserver.tty and/or display are set to null, then don't specify
  them, or the -logfile argument in the xserverArgs
- For lightdm, we set default tty and display to null and we determine
  those at runtime based on arguments passed. This is necessary because
  we run multiple X servers so they can't all be on the same display
This commit is contained in:
obadz 2015-11-29 00:18:59 +00:00
parent c7738364b5
commit 9be012f0d4
3 changed files with 18 additions and 10 deletions

View file

@ -37,7 +37,7 @@ let
# file provided by services.xserver.displayManager.session.script
xsession = wm: dm: pkgs.writeScript "xsession"
''
#! /bin/sh
#! ${pkgs.bash}/bin/bash
. /etc/profile
cd "$HOME"

View file

@ -13,9 +13,16 @@ let
# lightdm runs with clearenv(), but we need a few things in the enviornment for X to startup
xserverWrapper = writeScript "xserver-wrapper"
''
#! /bin/sh
#! ${pkgs.bash}/bin/bash
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs}
display=$(echo "$@" | xargs -n 1 | grep -P ^:\\d\$ | head -n 1 | sed s/^://)
if [ -z "$display" ]
then additionalArgs=":0 -logfile /var/log/X.0.log"
else additionalArgs="-logfile /var/log/X.$display.log"
fi
exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs} $additionalArgs "$@"
'';
usersConf = writeText "users.conf"
@ -39,7 +46,6 @@ let
greeter-session = ${cfg.greeter.name}
${cfg.extraSeatDefaults}
'';
in
{
# Note: the order in which lightdm greeter modules are imported
@ -98,7 +104,6 @@ in
};
config = mkIf cfg.enable {
services.xserver.displayManager.slim.enable = false;
services.xserver.displayManager.job = {
@ -149,5 +154,7 @@ in
services.xserver.displayManager.lightdm.background = mkDefault "${pkgs.nixos-artwork}/share/artwork/gnome/Gnome_Dark.png";
services.xserver.tty = null; # We might start multiple X servers so let the tty increment themselves..
services.xserver.display = null; # We specify our own display (and logfile) in xserver-wrapper up there
};
}

View file

@ -381,13 +381,13 @@ in
};
tty = mkOption {
type = types.int;
type = types.nullOr types.int;
default = 7;
description = "Virtual console for the X server.";
};
display = mkOption {
type = types.int;
type = types.nullOr types.int;
default = 0;
description = "Display number for the X server.";
};
@ -517,11 +517,12 @@ in
services.xserver.displayManager.xserverArgs =
[ "-ac"
"-terminate"
"-logfile" "/var/log/X.${toString cfg.display}.log"
"-config ${configFile}"
":${toString cfg.display}" "vt${toString cfg.tty}"
"-xkbdir" "${pkgs.xkeyboard_config}/etc/X11/xkb"
] ++ optional (!cfg.enableTCP) "-nolisten tcp";
] ++ optional (cfg.display != null) ":${tostring cfg.display}"
++ optional (cfg.tty != null) "vt${toString cfg.tty}"
++ optional (cfg.display != null) [ "-logfile" "/var/log/X.${toString cfg.display}.log" ]
++ optional (!cfg.enableTCP) "-nolisten tcp";
services.xserver.modules =
concatLists (catAttrs "modules" cfg.drivers) ++