nixos/x11: start session with dbus-launch

This is needed by most window managers. Desktop environments
usually launch dbus-launch if a session hasn't been started yet
so this shouldn't hurt. The worst it can happen is that one
dbus session will be unused in case it's started twice.

The GDM change is backported from recent gdm.

Changed files
+35 -2
nixos
modules
services
x11
display-managers
pkgs
desktops
gnome-3
+6
nixos/modules/services/x11/display-managers/default.nix
···
exec > ~/.xsession-errors 2>&1
''}
+
${optionalString cfg.startDbusSession ''
+
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
+
exec ${pkgs.dbus.tools}/bin/dbus-launch --exit-with-session "$0" "$sessionType"
+
fi
+
''}
+
${optionalString cfg.displayManager.desktopManagerHandlesLidAndPower ''
# Stop systemd from handling the power button and lid switch,
# since presumably the desktop environment will handle these.
+8
nixos/modules/services/x11/xserver.nix
···
'';
};
+
startDbusSession = mkOption {
+
type = types.bool;
+
default = true;
+
description = ''
+
Whether to start a new DBus session when you log in with dbus-launch.
+
'';
+
};
+
layout = mkOption {
type = types.str;
default = "us";
+1 -2
pkgs/desktops/gnome-3/3.16/core/gdm/default.nix
···
preBuild = ''
substituteInPlace daemon/gdm-simple-slave.c --replace 'BINDIR "/gnome-session' '"${gnome_session}/bin/gnome-session'
-
substituteInPlace daemon/gdm-launch-environment.c --replace 'BINDIR "/dbus-launch' '"${dbus.tools}/bin/dbus-launch'
'';
# Disable Access Control because our X does not support FamilyServerInterpreted yet
-
patches = [ ./xserver_path.patch ./sessions_dir.patch ./disable_x_access_control.patch ];
+
patches = [ ./xserver_path.patch ./sessions_dir.patch ./disable_x_access_control.patch ./no-dbus-launch.patch ];
meta = with stdenv.lib; {
homepage = https://wiki.gnome.org/Projects/GDM;
+20
pkgs/desktops/gnome-3/3.16/core/gdm/no-dbus-launch.patch
···
+
--- a/daemon/gdm-launch-environment.c 2015-06-22 15:11:07.277474398 +0000
+
+++ b/daemon/gdm-launch-environment.c 2015-06-22 15:12:31.301157665 +0000
+
@@ -48,8 +48,6 @@
+
#include "gdm-session-enum-types.h"
+
#include "gdm-launch-environment.h"
+
+
-#define DBUS_LAUNCH_COMMAND BINDIR "/dbus-launch --exit-with-session"
+
-
+
extern char **environ;
+
+
#define GDM_LAUNCH_ENVIRONMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LAUNCH_ENVIRONMENT, GdmLaunchEnvironmentPrivate))
+
@@ -512,7 +510,7 @@
+
gdm_session_select_program (launch_environment->priv->session, launch_environment->priv->command);
+
} else {
+
/* wrap it in dbus-launch */
+
- char *command = g_strdup_printf ("%s %s", DBUS_LAUNCH_COMMAND, launch_environment->priv->command);
+
+ char *command = g_strdup (launch_environment->priv->command);
+
+
gdm_session_select_program (launch_environment->priv->session, command);
+
g_free (command);