From f00440fac5552b92098c020946a2ac45a2fe613b Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Mon, 22 Jun 2015 16:08:29 +0000 Subject: [PATCH] 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. --- .../services/x11/display-managers/default.nix | 6 ++++++ nixos/modules/services/x11/xserver.nix | 8 ++++++++ .../gnome-3/3.16/core/gdm/default.nix | 3 +-- .../3.16/core/gdm/no-dbus-launch.patch | 20 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 pkgs/desktops/gnome-3/3.16/core/gdm/no-dbus-launch.patch diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 736621a14a43..7e05cd84be64 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -50,6 +50,12 @@ let 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. diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 9fddc6a72104..1ec098fded6e 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -238,6 +238,14 @@ in ''; }; + 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"; diff --git a/pkgs/desktops/gnome-3/3.16/core/gdm/default.nix b/pkgs/desktops/gnome-3/3.16/core/gdm/default.nix index 43a3d450ac72..17245bd9d2a9 100644 --- a/pkgs/desktops/gnome-3/3.16/core/gdm/default.nix +++ b/pkgs/desktops/gnome-3/3.16/core/gdm/default.nix @@ -27,11 +27,10 @@ stdenv.mkDerivation rec { 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; diff --git a/pkgs/desktops/gnome-3/3.16/core/gdm/no-dbus-launch.patch b/pkgs/desktops/gnome-3/3.16/core/gdm/no-dbus-launch.patch new file mode 100644 index 000000000000..c87554078c7c --- /dev/null +++ b/pkgs/desktops/gnome-3/3.16/core/gdm/no-dbus-launch.patch @@ -0,0 +1,20 @@ +--- 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);