summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosselin Poiret <josselin.poiret@protonmail.ch>2021-09-13 07:45:06 +0000
committerMathieu Othacehe <othacehe@gnu.org>2021-10-02 17:17:44 +0000
commit5c3f0c3e03757b6653f4c2386a526a2d9d6532f7 (patch)
tree198208aa5bf83200d37abee56ce724e2b78d8ea4
parentfc24bcb86fb68e1e69c168d5de7d94f01148c9cd (diff)
downloadguix-5c3f0c3e03757b6653f4c2386a526a2d9d6532f7.tar.gz
gnu: Add Wayland support for GDM.
Add the optional flag `wayland?` in `gdm-configuration` to launch GDM with
Wayland, enabling the use of Wayland sessions with GDM.

* gnu/packages/patches/gdm-remove-hardcoded-xwayland-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/gnome.scm (gdm): Use it.
* gnu/services/xorg.scm (<gdm-configuration>)[wayland?]: New field.
(gdm-configuration): Honor it.
(gdm-shepherd-service): Add the XCURSOR_PATH environment variable.
* doc/guix.texi (X Window): Document it

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
-rw-r--r--doc/guix.texi34
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/gnome.scm4
-rw-r--r--gnu/packages/patches/gdm-remove-hardcoded-xwayland-path.patch22
-rw-r--r--gnu/services/xorg.scm15
5 files changed, 60 insertions, 16 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 9f6604117c..6d925a44b8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -96,6 +96,7 @@ Copyright @copyright{} 2021 Domagoj Stolfa@*
 Copyright @copyright{} 2021 Hui Lu@*
 Copyright @copyright{} 2021 pukkamustard@*
 Copyright @copyright{} 2021 Alice Brenon@*
+Copyright @copyright{} 2021 Josselin Poiret@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -18253,19 +18254,26 @@ example the @code{windowmaker} or @code{openbox} packages---preferably
 by adding it to the @code{packages} field of your operating system
 definition (@pxref{operating-system Reference, system-wide packages}).
 
+@anchor{wayland-gdm}
+GDM also supports Wayland: it can itself use Wayland instead of X11 for
+its user interface, and it can also start Wayland sessions.  The former is
+required for the latter, to enable, set @code{wayland?} to @code{#t} in
+@code{gdm-configuration}.
+
 @defvr {Scheme Variable} gdm-service-type
 This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
 Desktop Manager} (GDM), a program that manages graphical display servers and
 handles graphical user logins.  Its value must be a @code{gdm-configuration}
 (see below).
 
-@cindex session types (X11)
-@cindex X11 session types
+@cindex session types
 GDM looks for @dfn{session types} described by the @file{.desktop} files in
-@file{/run/current-system/profile/share/xsessions} and allows users to choose
-a session from the log-in screen.  Packages such as @code{gnome}, @code{xfce},
-and @code{i3} provide @file{.desktop} files; adding them to the system-wide
-set of packages automatically makes them available at the log-in screen.
+@file{/run/current-system/profile/share/xsessions} (for X11 sessions) and
+@file{/run/current-system/profile/share/wayland-sessions} (for Wayland
+sessions) and allows users to choose a session from the log-in screen.
+Packages such as @code{gnome}, @code{xfce}, @code{i3} and @code{sway} provide
+@file{.desktop} files; adding them to the system-wide set of packages
+automatically makes them available at the log-in screen.
 
 In addition, @file{~/.xsession} files are honored.  When available,
 @file{~/.xsession} must be an executable that starts a window manager
@@ -18298,6 +18306,9 @@ File name of the @code{dbus-daemon} executable.
 
 @item @code{gdm} (default: @code{gdm})
 The GDM package to use.
+
+@item @code{wayland?} (default: @code{#f})
+When true, enables Wayland in GDM, necessary to use Wayland sessions.
 @end table
 @end deftp
 
@@ -19526,11 +19537,12 @@ expected.
 
 The desktop environments in Guix use the Xorg display server by
 default.  If you'd like to use the newer display server protocol
-called Wayland, you need to use the @code{sddm-service} instead of
-GDM as the graphical login manager.  You should then
-select the ``GNOME (Wayland)'' session in SDDM@.  Alternatively you can
-also try starting GNOME on Wayland manually from a TTY with the
-command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
+called Wayland, you need to enable Wayland support in GDM
+(@pxref{wayland-gdm}).  Another solution is to use the
+@code{sddm-service} instead of GDM as the graphical login manager.
+You should then select the ``GNOME (Wayland)'' session in SDDM@.
+Alternatively you can also try starting GNOME on Wayland manually from a
+TTY with the command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
 gnome-session``.  Currently only GNOME has support for Wayland.
 
 @defvr {Scheme Variable} gnome-desktop-service-type
diff --git a/gnu/local.mk b/gnu/local.mk
index 160e651624..cc2a634d37 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1101,6 +1101,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gd-Revert-fix-303-gdlib.pc-use-Requires-instead-of-Libs.patch	\
   %D%/packages/patches/gdm-default-session.patch		\
   %D%/packages/patches/gdm-elogind-support.patch		\
+  %D%/packages/patches/gdm-remove-hardcoded-xwayland-path.patch	\
   %D%/packages/patches/geary-CVE-2020-24661.patch		\
   %D%/packages/patches/genimage-signedness.patch		\
   %D%/packages/patches/geoclue-config.patch			\
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index cf3a4e79fa..f0a8a4265d 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -63,6 +63,7 @@
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2021 Josselin Poiret <josselin.poiret@protonmail.ch>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -8148,7 +8149,8 @@ library.")
               (patches
                (search-patches
                 "gdm-default-session.patch"
-                "gdm-elogind-support.patch"))))
+                "gdm-elogind-support.patch"
+                "gdm-remove-hardcoded-xwayland-path.patch"))))
     (build-system meson-build-system)
     (arguments
      `(#:glib-or-gtk? #t
diff --git a/gnu/packages/patches/gdm-remove-hardcoded-xwayland-path.patch b/gnu/packages/patches/gdm-remove-hardcoded-xwayland-path.patch
new file mode 100644
index 0000000000..366fb91668
--- /dev/null
+++ b/gnu/packages/patches/gdm-remove-hardcoded-xwayland-path.patch
@@ -0,0 +1,22 @@
+Remove check for hardcoded Xwayland path in gdm.
+
+---
+ daemon/gdm-local-display-factory.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
+index da1093bb..37355c06 100644
+--- a/daemon/gdm-local-display-factory.c
++++ b/daemon/gdm-local-display-factory.c
+@@ -203,7 +203,7 @@ gdm_local_display_factory_use_wayland (void)
+ #ifdef ENABLE_WAYLAND_SUPPORT
+         gboolean wayland_enabled = FALSE;
+         if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
+-                if (wayland_enabled && g_file_test ("/usr/bin/Xwayland", G_FILE_TEST_IS_EXECUTABLE) )
++                if (wayland_enabled)
+                         return TRUE;
+         }
+ #endif
+--
+2.33.0
+
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index d5c5316d3f..30b261453b 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -10,6 +10,7 @@
 ;;; Copyright © 2020 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2021 Josselin Poiret <josselin.poiret@protonmail.ch>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -883,7 +884,8 @@ the GNOME desktop environment.")
   (xorg-configuration gdm-configuration-xorg
                       (default (xorg-configuration)))
   (x-session gdm-configuration-x-session
-             (default (xinitrc))))
+             (default (xinitrc)))
+  (wayland? gdm-configuration-wayland? (default #f)))
 
 (define (gdm-configuration-file config)
   (mixed-text-file "gdm-custom.conf"
@@ -909,8 +911,9 @@ the GNOME desktop environment.")
                    ;; See also
                    ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39281>.
                    "InitialSetupEnable=false\n"
-                   ;; Enable me once X is working.
-                   "WaylandEnable=false\n"
+                   "WaylandEnable=" (if (gdm-configuration-wayland? config)
+                                        "true"
+                                        "false") "\n"
                    "\n"
                    "[debug]\n"
                    "Enable=" (if (gdm-configuration-debug? config)
@@ -976,7 +979,11 @@ the GNOME desktop environment.")
                                   ;; can depend on GNOME Shell directly.
                                   (cons #$gnome-shell
                                         '#$(gdm-configuration-gnome-shell-assets
-                                            config)))))))))
+                                            config)))))
+                           ;; Add XCURSOR_PATH so that mutter can find its
+                           ;; cursors.  gdm doesn't login so doesn't source
+                           ;; the corresponding line in /etc/profile.
+                           "XCURSOR_PATH=/run/current-system/profile/share/icons"))))
          (stop #~(make-kill-destructor))
          (respawn? #t))))