all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Josselin Poiret <dev@jpoiret.xyz>
To: Mathieu Othacehe <othacehe@gnu.org>
Cc: "50563@debbugs.gnu.org" <50563@debbugs.gnu.org>
Subject: [bug#50563] [PATCH [0/2] gnu: GDM: Add Wayland support
Date: Sat, 02 Oct 2021 16:51:34 +0000	[thread overview]
Message-ID: <dOdQ9VarjnqorXfOtKz_0I8J34K70GFG-GUHkjAFPosZDyqQfRsAFGE8PDDXhTj1X620LZ38aHqIlJJukmmC74BJfXHUGNyklOhRHw2TSMs=@jpoiret.xyz> (raw)
In-Reply-To: <87v92hp0kb.fsf@gnu.org>

On Friday, October 1st, 2021 at 9:16 AM, Mathieu Othacehe <othacehe@gnu.org> wrote:
> I see that for explaining! This would deserve a comment I think, could
> you please send a v2 for the second patch?

* gnu/packages/patches/gdm-wayland-session-wrapper-from-env.patch: Patch GDM to support launching a wrapper script for Wayland sessions.
* gnu/services/xorg.scm (gdm-configuration): Add `wayland-session` in `gdm-configuration` to
specify the wrapper to use.
* gnu/services/xorg.scm (gdm-wayland-session-wrapper): Add default wrapper that runs non-GDM sessions through a login shell (based
on the `xinitrc`).
* doc/guix.texi: Update the documentation with those changes.
---
 doc/guix.texi                                 |  4 +++
 gnu/packages/gnome.scm                        |  3 +-
 ...gdm-wayland-session-wrapper-from-env.patch | 35 +++++++++++++++++++
 gnu/services/xorg.scm                         | 25 +++++++++++--
 4 files changed, 64 insertions(+), 3 deletions(-)
 create mode 100644 gnu/packages/patches/gdm-wayland-session-wrapper-from-env.patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 9e80a2c397..21c1fc04e1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18201,6 +18201,10 @@ The GDM package to use.

 @item @code{wayland?} (default: @code{#f})
 When true, enables Wayland in GDM, necessary to use Wayland sessions.
+
+@item @code{wayland-session} (default: @code{gdm-wayland-session-wrapper})
+The Wayland session wrapper to use, needed to setup the
+environment.
 @end table
 @end deftp

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index f155867dfc..ca4d00917d 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -8112,7 +8112,8 @@ library.")
                (base32
                 "1lyqvcwxhwxklbxn4xjswjzr6fhjix6h28mi9ypn34wdm9bzcpg8"))
               (patches (search-patches "gdm-default-session.patch"
-                                       "gdm-remove-hardcoded-xwayland-path.patch"))))
+                                       "gdm-remove-hardcoded-xwayland-path.patch"
+                                       "gdm-wayland-session-wrapper-from-env.patch"))))
     (build-system glib-or-gtk-build-system)
     (arguments
      '(#:configure-flags
diff --git a/gnu/packages/patches/gdm-wayland-session-wrapper-from-env.patch b/gnu/packages/patches/gdm-wayland-session-wrapper-from-env.patch
new file mode 100644
index 0000000000..ca1af557ef
--- /dev/null
+++ b/gnu/packages/patches/gdm-wayland-session-wrapper-from-env.patch
@@ -0,0 +1,35 @@
+Get wayland-session wrapper from environment
+
+---
+ daemon/gdm-session.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
+index 4e303e70..1deca4e9 100644
+--- a/daemon/gdm-session.c
++++ b/daemon/gdm-session.c
+@@ -2888,8 +2888,9 @@ gdm_session_start_session (GdmSession *self,
+                                                            allow_remote_connections? "--allow-remote-connections " : "",
+                                                            command);
+                         } else {
+-                                program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s\"",
++                                program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s %s\"",
+                                                            register_session ? "--register-session " : "",
++                                                           g_getenv ("GDM_WAYLAND_SESSION"),
+                                                            command);
+                         }
+                 } else if (run_xsession_script) {
+@@ -2906,8 +2907,9 @@ gdm_session_start_session (GdmSession *self,
+                                                            register_session ? "--register-session " : "",
+                                                            self->selected_program);
+                         } else {
+-                                program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s\"",
++                                program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s %s\"",
+                                                            register_session ? "--register-session " : "",
++                                                           g_getenv ("GDM_WAYLAND_SESSION"),
+                                                            self->selected_program);
+                         }
+                 } else {
+--
+2.33.0
+
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index fe25168a58..122dd14ae2 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -869,6 +869,23 @@ the GNOME desktop environment.")
        (apply execl (string-append #$dbus "/bin/dbus-daemon")
               (program-arguments)))))

+;; Wrapper script for Wayland sessions, similar to Xsession. See `xinitrc`.
+;; By default, launches the specified session through a login shell.
+;; With default Guix configuration, this should source /etc/profile,
+;; setting up Guix profile environment variables.
+;; However, gdm launches its own graphical session through the same method, so
+;; we need to ignore this case, since `gdm` doesn't have a login shell.
+(define gdm-wayland-session-wrapper
+  (program-file
+   "gdm-wayland-session-wrapper"
+   #~((let* ((user (getpw (getuid)))
+	    (name (passwd:name user))
+	    (shell (passwd:shell user))
+	    (args (cdr (command-line))))
+        (if (string=? name "gdm")
+	    (apply execl (cons (car args) args))
+	    (execl shell shell "--login" "-c" (string-join args)))))))
+
 (define-record-type* <gdm-configuration>
   gdm-configuration make-gdm-configuration
   gdm-configuration?
@@ -884,7 +901,8 @@ the GNOME desktop environment.")
                       (default (xorg-configuration)))
   (x-session gdm-configuration-x-session
              (default (xinitrc)))
-  (wayland? gdm-configuration-wayland? (default #f)))
+  (wayland? gdm-configuration-wayland? (default #f))
+  (wayland-session gdm-configuration-wayland-session (default gdm-wayland-session-wrapper)))

 (define (gdm-configuration-file config)
   (mixed-text-file "gdm-custom.conf"
@@ -982,7 +1000,10 @@ the GNOME desktop environment.")
                            ;; 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"))))
+                           "XCURSOR_PATH=/run/current-system/profile/share/icons"
+                           (string-append
+                            "GDM_WAYLAND_SESSION="
+                            #$(gdm-configuration-wayland-session config))))))
          (stop #~(make-kill-destructor))
          (respawn? #t))))

--
2.33.0

> That's unrelated, but what's your take on enabling wayland by default on
> GDM, like some other distributions? Just ran a quick search and it looks
> like it could be problematic for Nvidia users.

I'd be mostly in favor of it, as this makes the experience smoother when trying to use a Wayland compositor "out-of-the-box" (sway and such are getting quite popular).
For Nvidia users, they mostly are aware of the driver shortcomings (and it seems that the incompatibility will soon disappear anyway),
maybe a short heads-up in the documentation would suffice.

Thanks again for the review,
Josselin




  reply	other threads:[~2021-10-02 16:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13  7:35 [bug#50563] [PATCH [0/2] gnu: GDM: Add Wayland support Josselin Poiret
2021-09-13  7:45 ` [bug#50563] [PATCH 1/2] gnu: Add Wayland support for GDM Josselin Poiret via Guix-patches via
2021-09-13  7:49 ` [bug#50563] [PATCH 2/2] gnu: gdm: Add Wayland session wrapper script Josselin Poiret via Guix-patches via
2021-09-13  8:13 ` [bug#50563] [PATCH 1/2] gnu: Add Wayland support for GDM Josselin Poiret
2021-09-13  8:15 ` [bug#50563] [PATCH 2/2] gnu: gdm: Add Wayland session wrapper script Josselin Poiret
2021-09-13 18:14   ` Maxime Devos
2021-10-01  7:37   ` [bug#50563] [PATCH [0/2] gnu: GDM: Add Wayland support Mathieu Othacehe
2021-10-01  8:56     ` Josselin Poiret
2021-10-01  9:16       ` Mathieu Othacehe
2021-10-02 16:51         ` Josselin Poiret [this message]
2021-10-02 17:29           ` bug#50563: " Mathieu Othacehe
2021-09-13 15:43 ` [bug#50563] (No Subject) Josselin Poiret via Guix-patches via
2021-09-14  2:02   ` Jack Hill
2021-09-14 21:45 ` [bug#50563] Re: [bug#50563] [PATCH 2/2] gnu: gdm: Add Wayland session wrapper script Josselin Poiret
2021-09-15  9:47   ` Maxime Devos
2021-09-29 11:20 ` [bug#50563] [PATCH [0/2] gnu: GDM: Add Wayland support Mathieu Othacehe
2021-09-29 12:10   ` Mathieu Othacehe
2021-09-29 22:10     ` Josselin Poiret
2021-09-30  9:41       ` Mathieu Othacehe
2021-09-30 14:27         ` Josselin Poiret
2021-10-01  7:33           ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='dOdQ9VarjnqorXfOtKz_0I8J34K70GFG-GUHkjAFPosZDyqQfRsAFGE8PDDXhTj1X620LZ38aHqIlJJukmmC74BJfXHUGNyklOhRHw2TSMs=@jpoiret.xyz' \
    --to=dev@jpoiret.xyz \
    --cc=50563@debbugs.gnu.org \
    --cc=othacehe@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.