Nixpkgs: Investigate GNOME wayland support

Created on 18 Dec 2017  ·  19Comments  ·  Source: NixOS/nixpkgs

GNOME Wayland session can be run manually, see https://github.com/NixOS/nixpkgs/issues/5071#issuecomment-335394294

We might need to package few more things like flatpak (for portals, see #33371) and pipewire (for screen capture/remote access, done in #34507).

Then we will need to create a session file for the wayland session. For xsessions the code is here

https://github.com/NixOS/nixpkgs/blob/5450c225aeb0bc6e360463e628c65647355d9a66/nixos/modules/services/x11/display-managers/default.nix#L183-L202

but it would be great if we could re-use the already existing $(nix-build -A gnome3.gnome_session)/share/wayland-sessions/gnome.desktop.

GNOME

Most helpful comment

If you want a better debuggability, you can create a simple configuration, for example:

{ pkgs, config, ... }:
{
  environment.systemPackages = with pkgs; [
    gdb
    binutils # readelf
    rr
    file
    htop
    less
    dbus
    dfeet
  ];

  services.openssh.enable = true;
  hardware.pulseaudio.enable = false; # some x11-publish errors

  # add debugging symbols
  environment.enableDebugInfo = true;
  nixpkgs.config.packageOverrides = super: {
    gnome3 = super.gnome3 // {
      gdm = super.enableDebugging super.gnome3.gdm;
    };
  };

  services.xserver = {
    enable = true;
    layout = "cz";
    xkbVariant = "qwerty";

    desktopManager = {
      gnome3.enable = true;
    };

    displayManager = {
      gdm.enable = true;
      gdm.debug = true;
    };
  };

  users.extraUsers.j = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "";
    openssh.authorizedKeys.keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYbOlZydfRRCGCT08wdtPcpfSrgxMc6weDx3NcWrnMpVgxnMs3HozzkaS/hbcZUocn7XbCOyaxEd1O8Fuaw4JXpUBcMetpPXkQC+bZHQ3YsZZyzVgCXFPRF88QQj0nR7YVE1AeAifjk3TCODstTxit868V1639/TVIi5y5fC0/VbYG2Lt4AadNH67bRv8YiO3iTsHQoZPKD1nxA7yANHCuw38bGTHRhsxeVD+72ThbsYSZeA9dBrzACpEdnwyXclaoyIOnKdN224tu4+4ytgH/vH/uoUfL8SmzzIDvwZ4Ba2yHhZHs5iwsVjTvLe7jjE6I1u8qY7X8ofnanfNcsmz/ jtojnar@kaiser"];
  };

  systemd.coredump.enable = true;
  virtualisation.memorySize = 1024;
}

Then you can run nixos-rebuild build-vm -I nixpkgs=$HOME/Projects/nixpkgs -I nixos-config=gdm-test.nix --show-trace to build a virtual machine and env QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm to start it.

Then you can run ssh -p 2222 j@localhost to connect to the machine’s SSH, where you can execute journalctl -xafb to see the log.

It is also nice to add NoHostAuthenticationForLocalhost yes to your ~/.ssh/config to be able to log in with different local computers without having to clean ~/.ssh/known_hosts.

All 19 comments

After some investigation I got Gnome 3.26 up and running from a tty without removing networkmanager support from the build:

XDG_SESSION_TYPE=wayland dbus-run-session $(nix-build --no-out-link '<nixpkgs>' -A gnome3.gnome_session)/bin/gnome-session

Seems to run without any obvious issues.

Simply adding XDG_SESSION_TYPE=wayland to the existing session script doesn't seem to work though.

Cool, this indeed works, I verified in the looking glass.

I have been trying to make it run in GDM (for now with the existing infrastructure), here is what I found:

First I tried to force the session type as you proposed:

--- a/nixos/modules/services/x11/desktop-managers/gnome3.nix
@@ -164,7 +164,7 @@
           # Update user dirs as described in http://freedesktop.org/wiki/Software/xdg-user-dirs/
           ${pkgs.xdg-user-dirs}/bin/xdg-user-dirs-update

-          ${pkgs.gnome3.gnome_session}/bin/gnome-session ${optionalString cfg.debug "--debug"} &
+          XDG_SESSION_TYPE=wayland ${pkgs.gnome3.gnome_session}/bin/gnome-session ${optionalString cfg.debug "--debug"} &
           waitPID=$!
         '';
       };

Then there were crashes from missing org.gnome.SessionManager schemas, so I tried extending the XDG_DATA_DIRS like this:

--- a/nixos/modules/services/x11/desktop-managers/gnome3.nix
+++ b/nixos/modules/services/x11/desktop-managers/gnome3.nix
@@ -147,7 +147,7 @@
               export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
               export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
             fi
-          '') cfg.sessionPath}
+          '') (cfg.sessionPath ++ [ pkgs.gnome3.gnome_session ])}

           # Override default mimeapps
           export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${mimeAppsList}/share

But that did not seem to work, so I used the override, which fixed it for some reason:

--- a/nixos/modules/services/x11/desktop-managers/gnome3.nix
+++ b/nixos/modules/services/x11/desktop-managers/gnome3.nix
@@ -29,7 +29,7 @@
      mkdir -p $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
      cp -rf ${pkgs.gnome3.gsettings_desktop_schemas}/share/gsettings-schemas/gsettings-desktop-schemas*/glib-2.0/schemas/*.xml $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas

-     ${concatMapStrings (pkg: "cp -rf ${pkg}/share/gsettings-schemas/*/glib-2.0/schemas/*.xml $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas\n") cfg.extraGSettingsOverridePackages}
+     ${concatMapStrings (pkg: "cp -rf ${pkg}/share/gsettings-schemas/*/glib-2.0/schemas/*.xml $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas\n") (cfg.extraGSettingsOverridePackages ++ [pkgs.gnome3.gnome_session])}

      chmod -R a+w $out/share/gsettings-schemas/nixos-gsettings-overrides
      cat - > $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas/nixos-defaults.gschema.override <<- EOF

The session still did not start, though. The journal also contained “GdmSession: checking if file 'gnome3.desktop' is wayland session: no”. As GDM detects the session type by file path, I changed that:

--- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -186,9 +186,9 @@
       allowSubstitutes = false;
     }
     ''
-      mkdir -p "$out"
+      mkdir -p "$out/wayland-sessions/"
       ${concatMapStrings (n: ''
-        cat - > "$out/${n}.desktop" << EODESKTOP
+        cat - > "$out/wayland-sessions/${n}.desktop" << EODESKTOP
         [Desktop Entry]
         Version=1.0
         Type=XSession
--- a/nixos/modules/services/x11/display-managers/gdm.nix
+++ b/nixos/modules/services/x11/display-managers/gdm.nix
@@ -109,7 +109,7 @@
         environment = {
           GDM_X_SERVER_EXTRA_ARGS = toString
             (filter (arg: arg != "-terminate") cfg.xserverArgs);
-          GDM_SESSIONS_DIR = "${cfg.session.desktops}";
+          GDM_SESSIONS_DIR = "${cfg.session.desktops}/wayland-sessions";
           # Find the mouse
           XCURSOR_PATH = "~/.icons:${pkgs.gnome3.adwaita-icon-theme}/share/icons";
         };

At this point I gave up for now. The session handling is weird and convoluted (see, for example, https://github.com/NixOS/nixpkgs/issues/34101) and will require more investigation.

Hmm, found few more errors:

Feb 03 17:06:44 nixos xsession[1076]: /nix/store/7fwbvijx41xc21n4n3ngz1slg1mqp73m-xrdb-1.1.0/bin/xrdb: Can't open display ''

Fixed it using

--- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -100,14 +100,6 @@
       # This is required by user units using the session bus.
       ${config.systemd.package}/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS

-      # Load X defaults.
-      ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
-      if test -e ~/.Xresources; then
-          ${xorg.xrdb}/bin/xrdb -merge ~/.Xresources
-      elif test -e ~/.Xdefaults; then
-          ${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
-      fi
-

Then the gsettings issue mentioned by @samdroid-apps:

--- a/pkgs/desktops/gnome-3/core/gnome-session/default.nix
+++ b/pkgs/desktops/gnome-3/core/gnome-session/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, pkgconfig, gnome3, glib, dbus_glib, json_glib, upower
+{ fetchurl, stdenv, substituteAll, pkgconfig, gnome3, glib, dbus_glib, json_glib, upower
 , libxslt, intltool, makeWrapper, systemd, xorg, epoxy }:

 stdenv.mkDerivation rec {
@@ -13,7 +13,14 @@
       epoxy
     ];

-  # FIXME: glib binaries shouldn't be in .dev!
+  patches = [
+    # FIXME: glib binaries shouldn't be in .dev!
+    (substituteAll {
+      src = ./fix-paths.patch;
+      gsettings = "${glib.dev}/bin/gsettings";
+    })
+  ];
+
   preFixup = ''
     for desktopFile in $(grep -rl "Exec=gnome-session" $out/share)
     do
@@ -21,7 +28,6 @@
       sed -i "s,^Exec=gnome-session,Exec=$out/bin/gnome-session," $desktopFile
     done
     wrapProgram "$out/bin/gnome-session" \
-      --prefix PATH : "${glib.dev}/bin" \
       --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
       --suffix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
       --suffix XDG_DATA_DIRS : "${gnome3.gnome_shell}/share" \
--- /dev/null
+++ b/pkgs/desktops/gnome-3/core/gnome-session/fix-paths.patch
@@ -0,0 +1,11 @@
+--- a/gnome-session/gnome-session.in
++++ b/gnome-session/gnome-session.in
+@@ -13,7 +13,7 @@
+   fi
+ fi
+ 
+-SETTING=$(gsettings get org.gnome.system.locale region)
++SETTING=$(@gsettings@ get org.gnome.system.locale region)
+ REGION=${SETTING#\'}
+ REGION=${REGION%\'}
+ 

Still does not work:

Log

Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: trying to get updated username
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: PAM conversation returning 0: Success
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: state AUTHENTICATED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: trying to get updated username
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: username is 'j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: old-username='j' new-username='j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: attempting to change state to AUTHORIZED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: determining if authenticated user (password required:0) is authorized to session
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: state AUTHORIZED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: attempting to change state to ACCREDITED
Feb 03 17:28:56 nixos gdm-password][1071]: forwarding GDM_X_SERVER_EXTRA_ARGS= -config /nix/store/zzs6id2ab942z59hdkmq4gwy13asix0g-xserver.conf -xkbdir /nix/store/xc57m1xhsr9r3adlz4znd2mswimd9ppi-xkeyboard-config-2.22/etc/X11/xkb -logfile /dev/null -nolisten tcp
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'GDM_X_SERVER_EXTRA_ARGS=-config /nix/store/zzs6id2ab942z59hdkmq4gwy13asix0g-xserver.conf -xkbdir /nix/store/xc57m1xhsr9r3adlz4znd2mswimd9ppi-xkeyboard-config-2.22/etc/X11/xkb -logfile /dev/null -nolisten tcp'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'LOGNAME=j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'USER=j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'USERNAME=j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'HOME=/home/j'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'SHELL=/run/current-system/sw/bin/bash'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'PATH=/nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: state ACCREDITED
Feb 03 17:28:56 nixos gdm[766]: GdmSession: type wayland, program? no, seat seat0
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: session display mode set to new-vt
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'XDG_SESSION_TYPE=wayland'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: attempting to change state to ACCOUNT_DETAILS_SAVED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: saving account details for user j
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: attempting to change state to SESSION_OPENED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'XDG_VTNR=2'
Feb 03 17:28:56 nixos gdm-password][1071]: pam_unix(gdm-password:session): session opened for user j by (uid=0)
Feb 03 17:28:56 nixos systemd[1]: Started Session 4 of user j.
-- Subject: Unit session-4.scope has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-4.scope has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:28:56 nixos systemd-logind[745]: New session 4 of user j.
-- Subject: A new session 4 has been created for user j
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
-- 
-- A new session with the ID 4 has been created for the user j.
-- 
-- The leading process of the session is 1071.
Feb 03 17:28:56 nixos systemd-journald[480]: Suppressed 212 messages from /user.slice/user-132.slice
-- Subject: Messages from a service have been suppressed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: man:journald.conf(5)
-- 
-- A service has logged too many messages within a time period. Messages
-- from the service have been dropped.
-- 
-- Note that only messages from the service in question have been
-- dropped, other services' messages are unaffected.
-- 
-- The limits controlling when messages are dropped may be configured
-- with RateLimitIntervalSec= and RateLimitBurst= in
-- /etc/systemd/journald.conf. See journald.conf(5) for details.
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): GsmSystemd: received logind signal: SessionNew
Feb 03 17:28:56 nixos gnome-session-binary[907]: DEBUG(+): GsmSystemd: received logind signal: SessionNew
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): GsmSystemd: ignoring SessionNew signal
Feb 03 17:28:56 nixos gnome-session-binary[907]: DEBUG(+): GsmSystemd: ignoring SessionNew signal
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: state SESSION_OPENED
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Emitting 'session-opened' signal
Feb 03 17:28:56 nixos gdm[766]: GdmManager: Will start session when ready
Feb 03 17:28:56 nixos gdm[766]: GdmManager: start or jump to session
Feb 03 17:28:56 nixos gdm[766]: GdmManager: migrated: 0
Feb 03 17:28:56 nixos gdm[766]: GdmSession: type wayland, program? no, seat seat0
Feb 03 17:28:56 nixos gdm[766]: GdmManager: session has its display server, reusing our server for another login screen
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Creating D-Bus server for worker for session
Feb 03 17:28:56 nixos gdm[766]: GdmSession: D-Bus server for workers listening on unix:abstract=/tmp/dbus-toedvVqG
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Creating D-Bus server for greeters and such
Feb 03 17:28:56 nixos gdm[766]: GdmSession: D-Bus server for greeters listening on unix:abstract=/tmp/dbus-0OLrAKDa
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Setting display device: (null)
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: id: (null)
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: seat id: (null)
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: session class: greeter
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: initial: no
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: allow timed login: yes
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: local: yes
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: session class: user
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: seat id: seat0
Feb 03 17:28:56 nixos gdm[766]: GdmDisplay: session id: 4
Feb 03 17:28:56 nixos gdm[766]: GdmDisplayStore: Adding display /org/gnome/DisplayManager/Displays/19723344 to store
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Stopping all conversations except for gdm-password
Feb 03 17:28:56 nixos gdm[766]: GdmSession: type wayland, program? no, seat seat0
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos gdm[766]: GdmSession: checking if file 'gnome3.desktop' is wayland session: yes
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Session (null) bypasses Xsession wrapper script
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "fd" "20"
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event2  - (II) Power Button: (II) device removed
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "fd" "23"
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event1  - (II) QEMU QEMU USB Tablet: (II) device removed
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "fd" "24"
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event0  - (II) AT Translated Set 2 keyboard: (II) device removed
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting session command for file 'gnome3.desktop'
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "fd" "25"
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event3  - (II) ImExPS/2 Generic Explorer Mouse: (II) device removed
Feb 03 17:28:56 nixos gdm[766]: GdmSession: getting desktop names for file 'gnome3.desktop'
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): emitting SessionIsActive
Feb 03 17:28:56 nixos gdm[766]: GdmSession: type wayland, program? no, seat seat0
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'LANG=en_US.UTF-8'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'GDMSESSION=gnome3'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'XDG_SESSION_DESKTOP=gnome3'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'DESKTOP_SESSION=gnome3'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: Set PAM environment variable: 'GDM_LANG=en_US.UTF-8'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: start program: /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-wayland-session "/nix/store/7ff5lvyhwggk303d35vjpi19dna14l5y-xsession "gnome3""
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: attempting to change state to SESSION_STARTED
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got pause for 13:65
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got pause for 13:64
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got pause for 13:67
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got pause for 226:0
Feb 03 17:28:56 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got pause for 13:66
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: opening user session with program '/nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-wayland-session'
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: jumping to VT 2
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: first setting graphics mode to prevent flicker
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: VT mode did not need to be fixed
Feb 03 17:28:56 nixos gdm-password][1071]: Trying script /etc/gdm/PostLogin
Feb 03 17:28:56 nixos gdm-password][1071]: script /etc/gdm/PostLogin not found; skipping
Feb 03 17:28:56 nixos gdm-password][1071]: Trying script /etc/gdm/PostLogin/Default
Feb 03 17:28:56 nixos gdm-password][1071]: script /etc/gdm/PostLogin/Default not found; skipping
Feb 03 17:28:56 nixos gdm-password][1071]: no script found
Feb 03 17:28:56 nixos gdm-password][1071]: Trying script /etc/gdm/PreSession
Feb 03 17:28:56 nixos gdm-password][1071]: script /etc/gdm/PreSession not found; skipping
Feb 03 17:28:56 nixos gdm-password][1071]: Trying script /etc/gdm/PreSession/Default
Feb 03 17:28:56 nixos gdm-password][1071]: script /etc/gdm/PreSession/Default not found; skipping
Feb 03 17:28:56 nixos gdm-password][1071]: no script found
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: session opened creating reply...
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSessionWorker: state SESSION_STARTED
Feb 03 17:28:56 nixos gdm-password][1071]: GdmSession worker: watching pid 1082
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Emitting 'session-started' signal with pid '1082'
Feb 03 17:28:56 nixos gdm[766]: GdmManager: session started 1082
Feb 03 17:28:56 nixos gnome-session-binary[907]: DEBUG(+): emitting SessionIsActive
Feb 03 17:28:56 nixos gdm-wayland-session[1082]: Enabling debugging
Feb 03 17:28:56 nixos gdm-wayland-session[1082]: Running session message bus
Feb 03 17:28:56 nixos gdm-wayland-session[1082]: session message bus already running, not starting another one
Feb 03 17:28:56 nixos gdm-wayland-session[1082]: Running wayland session
Feb 03 17:28:56 nixos gdm[766]: GdmManager: trying to register new display
Feb 03 17:28:56 nixos gdm[766]: GdmSession: Setting display device: /dev/tty2
Feb 03 17:28:56 nixos gdm[766]: using ut_user j
Feb 03 17:28:56 nixos gdm[766]: Writing login record
Feb 03 17:28:56 nixos gdm[766]: using ut_type USER_PROCESS
Feb 03 17:28:56 nixos gdm[766]: using ut_tv time 1517678936
Feb 03 17:28:56 nixos gdm[766]: using ut_pid 1082
Feb 03 17:28:56 nixos gdm[766]: using ut_host /dev/tty2
Feb 03 17:28:56 nixos gdm[766]: using ut_line tty2
Feb 03 17:28:56 nixos gdm[766]: Writing wtmp session record to /var/log/wtmp
Feb 03 17:28:56 nixos gdm[766]: Adding or updating utmp record for login
Feb 03 17:28:56 nixos gdm[766]: GdmLocalDisplayFactory: display status changed: 2
Feb 03 17:28:57 nixos rtkit-daemon[940]: Successfully made thread 1109 of process 1109 (/nix/store/2vmhr1fnw7p2ac9wkb2gkrx2rnq70ywn-pulseaudio-11.0/bin/pulseaudio) owned by 'j' high priority at nice level -11.
Feb 03 17:28:57 nixos rtkit-daemon[940]: Supervising 1 threads of 1 processes of 1 users.
Feb 03 17:28:57 nixos systemd[855]: Starting Sound Service...
-- Subject: Unit UNIT has begun start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has begun starting up.
Feb 03 17:28:57 nixos pulseaudio[1109]: bind(): Address already in use
Feb 03 17:28:57 nixos pulseaudio[1109]: Failed to load module "module-native-protocol-unix" (argument: ""): initialization failed.
Feb 03 17:28:57 nixos pulseaudio[1109]: Module load failed.
Feb 03 17:28:57 nixos pulseaudio[1109]: Failed to initialize daemon.
Feb 03 17:28:57 nixos xsession[1085]: E: [pulseaudio] main.c: Daemon startup failed.
Feb 03 17:28:57 nixos rtkit-daemon[940]: Successfully made thread 1110 of process 1110 (/nix/store/2vmhr1fnw7p2ac9wkb2gkrx2rnq70ywn-pulseaudio-11.0/bin/pulseaudio) owned by 'j' high priority at nice level -11.
Feb 03 17:28:57 nixos rtkit-daemon[940]: Supervising 1 threads of 1 processes of 1 users.
Feb 03 17:28:57 nixos systemd[855]: Started Sound Service.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:28:57 nixos pulseaudio[1110]: E: [pulseaudio] ltdl-bind-now.c: Failed to open module module-x11-publish.so: module-x11-publish.so: cannot open shared object file: No such file or directory
Feb 03 17:28:57 nixos pulseaudio[1110]: E: [pulseaudio] module.c: Failed to open module "module-x11-publish".
Feb 03 17:28:57 nixos xsession[1085]: Failure: Module initialization failed
Feb 03 17:28:57 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: sending user-changed signal for user j
Feb 03 17:28:57 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: sent user-changed signal for user j
Feb 03 17:28:57 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: updating user j
Feb 03 17:28:57 nixos gdm-password][1071]: AccountsService: ActUserManager: sending user-changed signal for user j
Feb 03 17:28:57 nixos gdm-password][1071]: AccountsService: ActUserManager: sent user-changed signal for user j
Feb 03 17:28:57 nixos gdm-password][1071]: AccountsService: ActUserManager: updating user j
Feb 03 17:28:57 nixos systemd[855]: Reached target Current graphical user session.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:28:57 nixos xsession[1085]: /nix/store/7ff5lvyhwggk303d35vjpi19dna14l5y-xsession: Window manager 'gnome3' not found.
Feb 03 17:28:57 nixos dbus-daemon[886]: Activating via systemd: service name='org.gtk.vfs.Daemon' unit='gvfs-daemon.service'
Feb 03 17:28:57 nixos systemd[855]: Starting Virtual filesystem service...
-- Subject: Unit UNIT has begun start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has begun starting up.
Feb 03 17:28:58 nixos dbus-daemon[886]: Successfully activated service 'org.gtk.vfs.Daemon'
Feb 03 17:28:58 nixos systemd[855]: Started Virtual filesystem service.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:28:58 nixos kernel: fuse init (API version 7.26)
Feb 03 17:28:58 nixos systemd[1]: Mounting FUSE Control File System...
-- Subject: Unit sys-fs-fuse-connections.mount has begun start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sys-fs-fuse-connections.mount has begun starting up.
Feb 03 17:28:58 nixos systemd[1]: Mounted FUSE Control File System.
-- Subject: Unit sys-fs-fuse-connections.mount has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sys-fs-fuse-connections.mount has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:28:58 nixos gnome-session-binary[1119]: Entering running state
Feb 03 17:28:58 nixos gnome-session-f[1172]: Cannot open display: 
Feb 03 17:29:00 nixos systemd[855]: Stopping D-Bus User Message Bus...
-- Subject: Unit UNIT has begun shutting down
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has begun shutting down.
Feb 03 17:29:00 nixos gvfsd[1148]: A connection to the bus can't be made
Feb 03 17:29:00 nixos systemd[855]: Stopped D-Bus User Message Bus.
-- Subject: Unit UNIT has finished shutting down
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished shutting down.
Feb 03 17:29:00 nixos systemd[855]: Started D-Bus User Message Bus.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Feb 03 17:29:00 nixos gdm-password][1071]: GdmSessionWorker: child (pid:1082) done (status:0)
Feb 03 17:29:00 nixos gdm-password][1071]: GdmSessionWorker: uninitializing PAM
Feb 03 17:29:00 nixos gdm-password][1071]: pam_unix(gdm-password:session): session closed for user j
Feb 03 17:29:00 nixos gdm-password][1071]: GdmSessionWorker: jumping to VT 7
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got resume for 13:65
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got resume for 13:64
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got resume for 13:67
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got resume for 226:0
Feb 03 17:29:00 nixos gdm-password][1071]: GdmSessionWorker: state NONE
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): emitting SessionIsActive
Feb 03 17:29:00 nixos gdm-password][1071]: Trying script /etc/gdm/PostSession
Feb 03 17:29:00 nixos gdm-password][1071]: script /etc/gdm/PostSession not found; skipping
Feb 03 17:29:00 nixos gdm-password][1071]: Trying script /etc/gdm/PostSession/Default
Feb 03 17:29:00 nixos gdm-password][1071]: script /etc/gdm/PostSession/Default not found; skipping
Feb 03 17:29:00 nixos gdm-password][1071]: no script found
Feb 03 17:29:00 nixos gdm[766]: GdmSession: Emitting 'session-exited' signal with exit code '0'
Feb 03 17:29:00 nixos gdm[766]: GdmManager: session exited with status 0
Feb 03 17:29:00 nixos gdm[766]: Writing logout record
Feb 03 17:29:00 nixos gdm[766]: using ut_type DEAD_PROCESS
Feb 03 17:29:00 nixos gdm[766]: using ut_tv time 1517678940
Feb 03 17:29:00 nixos gdm[766]: using ut_pid 1082
Feb 03 17:29:00 nixos gdm[766]: using ut_host /dev/tty2
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "Device" "/dev/input/event1"
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event1  - (II) QEMU QEMU USB Tablet: (II) is tagged by udev as: Mouse
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event1  - (II) QEMU QEMU USB Tablet: (II) device is a pointer
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "Device" "/dev/input/event0"
Feb 03 17:29:00 nixos gdm[766]: using ut_line tty2
Feb 03 17:29:00 nixos systemd-logind[745]: Removed session 4.
-- Subject: Session 4 has been terminated
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
-- 
-- A session with the ID 4 has been terminated.
Feb 03 17:29:00 nixos gdm[766]: Writing wtmp logout record to /var/log/wtmp
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): GsmSystemd: received logind signal: SessionRemoved
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: gnome-session-binary[907]: DEBUG(+): GsmSystemd: ignoring SessionRemoved signal
Feb 03 17:29:00 nixos gnome-session-binary[907]: DEBUG(+): emitting SessionIsActive
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event0  - (II) AT Translated Set 2 keyboard: (II) is tagged by udev as: Keyboard
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event0  - (II) AT Translated Set 2 keyboard: (II) device is a keyboard
Feb 03 17:29:00 nixos gdm[766]: Adding or updating utmp record for logout
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "Device" "/dev/input/event3"
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event3  - (II) ImExPS/2 Generic Explorer Mouse: (II) is tagged by udev as: Mouse
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event3  - (II) ImExPS/2 Generic Explorer Mouse: (II) device is a pointer
Feb 03 17:29:00 nixos gdm[766]: GdmDisplay: unmanage display
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) systemd-logind: got resume for 13:66
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (**) Option "Device" "/dev/input/event2"
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event2  - (II) Power Button: (II) is tagged by udev as: Keyboard
Feb 03 17:29:00 nixos /nix/store/bspzn6ad2651c7q8nc8n0w762mlkwznf-gdm-3.26.2.1/libexec/gdm-x-session[888]: (II) event2  - (II) Power Button: (II) device is a keyboard
Feb 03 17:29:00 nixos gdm[766]: GdmLocalDisplayFactory: display status changed: 0
Feb 03 17:29:00 nixos gdm[766]: GdmLocalDisplayFactory: display status changed: 3
Feb 03 17:29:00 nixos gdm[766]: GdmDisplayStore: Unreffing display: 0x12cf450
Feb 03 17:29:00 nixos gdm[766]: GdmDisplay: finish display
Feb 03 17:29:00 nixos gdm[766]: GdmSession: Closing session
Feb 03 17:29:00 nixos gdm[766]: GdmSession: Stopping all conversations
Feb 03 17:29:00 nixos gdm[766]: GdmSessionWorkerJob: Stopping job pid:1071
Feb 03 17:29:00 nixos gdm[766]: GdmCommon: sending signal 15 to process 1071
Feb 03 17:29:00 nixos gdm[766]: GdmSessionWorkerJob: Waiting on process 1071
Feb 03 17:29:00 nixos gnome-session-binary[907]: DEBUG(+): GsmSystemd: received logind signal: SessionRemoved
Feb 03 17:29:00 nixos gnome-session-binary[907]: DEBUG(+): GsmSystemd: ignoring SessionRemoved signal
Feb 03 17:29:00 nixos .gsd-color-wrap[972]: unable to get EDID for xrandr-Virtual-1: unable to get EDID for output
Feb 03 17:29:00 nixos gdm[766]: GdmCommon: process (pid:1071) done (status:0)
Feb 03 17:29:00 nixos gdm[766]: GdmSessionWorkerJob: SessionWorkerJob died
Feb 03 17:29:00 nixos gdm[766]: GdmManager: trying to open new session
Feb 03 17:29:00 nixos gdm[766]: GdmDBusServer: new connection 0x12cfb80
Feb 03 17:29:00 nixos gdm[766]: GdmSession: Handling new connection from outside
Feb 03 17:29:00 nixos gdm[766]: GdmManager: client connected
Feb 03 17:29:00 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: sending user-changed signal for user j
Feb 03 17:29:00 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: sent user-changed signal for user j
Feb 03 17:29:00 nixos gdm-launch-environment][800]: AccountsService: ActUserManager: updating user j

Looking through the Fedora wayland-session desktop files, they use Type=Application. Currently, your patchset uses Type=XSession.

That gets it running, but then crashes due to a dbus service:

Feb 04 08:23:21 vcs .gnome-shell-wr[4503]: Error looking up permission: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.impl.portal.PermissionStore was not provided by any .service files

I'm on the following diff: https://github.com/NixOS/nixpkgs/compare/release-17.09...samdroid-apps:wayland-wip (which is basically just all your patches applied and the XSession->Application change)

@samdroid-apps I see this error in normal usage since 3.26 or 3.24 upgrade, it should not be a problem.

My branch: https://github.com/jtojnar/nixpkgs/tree/wayland-tryouts

(Replying from irc): Found the manual startup on the arch wiki, but doesn't look like there's much else of interest there. Searching for «wayland» in the gnome-session source code also surfaced a reference to XDG_SESSION_TYPE.

Tested out @samdroid-apps Application change (on top of the wayland-tryouts branch), which didn't work on the first try. So started gnome-shell up manually in wayland from a tty to get a better environment to debug from. Logging in through gdm then worked for some weird reason.

Edit: did a reboot and managed to reproduce it, posting from wayland logged in through gdm with screenlock working :)

If you want a better debuggability, you can create a simple configuration, for example:

{ pkgs, config, ... }:
{
  environment.systemPackages = with pkgs; [
    gdb
    binutils # readelf
    rr
    file
    htop
    less
    dbus
    dfeet
  ];

  services.openssh.enable = true;
  hardware.pulseaudio.enable = false; # some x11-publish errors

  # add debugging symbols
  environment.enableDebugInfo = true;
  nixpkgs.config.packageOverrides = super: {
    gnome3 = super.gnome3 // {
      gdm = super.enableDebugging super.gnome3.gdm;
    };
  };

  services.xserver = {
    enable = true;
    layout = "cz";
    xkbVariant = "qwerty";

    desktopManager = {
      gnome3.enable = true;
    };

    displayManager = {
      gdm.enable = true;
      gdm.debug = true;
    };
  };

  users.extraUsers.j = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "";
    openssh.authorizedKeys.keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYbOlZydfRRCGCT08wdtPcpfSrgxMc6weDx3NcWrnMpVgxnMs3HozzkaS/hbcZUocn7XbCOyaxEd1O8Fuaw4JXpUBcMetpPXkQC+bZHQ3YsZZyzVgCXFPRF88QQj0nR7YVE1AeAifjk3TCODstTxit868V1639/TVIi5y5fC0/VbYG2Lt4AadNH67bRv8YiO3iTsHQoZPKD1nxA7yANHCuw38bGTHRhsxeVD+72ThbsYSZeA9dBrzACpEdnwyXclaoyIOnKdN224tu4+4ytgH/vH/uoUfL8SmzzIDvwZ4Ba2yHhZHs5iwsVjTvLe7jjE6I1u8qY7X8ofnanfNcsmz/ jtojnar@kaiser"];
  };

  systemd.coredump.enable = true;
  virtualisation.memorySize = 1024;
}

Then you can run nixos-rebuild build-vm -I nixpkgs=$HOME/Projects/nixpkgs -I nixos-config=gdm-test.nix --show-trace to build a virtual machine and env QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm to start it.

Then you can run ssh -p 2222 j@localhost to connect to the machine’s SSH, where you can execute journalctl -xafb to see the log.

It is also nice to add NoHostAuthenticationForLocalhost yes to your ~/.ssh/config to be able to log in with different local computers without having to clean ~/.ssh/known_hosts.

Ah, thanks, that's handy. I'll take a look and see if I can figure out why it works when a wayland session is already started.

Doing some more debugging:

  • I saw gdm-x-session in the logs a lot, and thought it might not be launching with wayland. I added debugging statements to see the program that gdm was running, and it does actually run gdm-wayland-session. I believe that the x session is gdm itself.

  • Inside the qemu environment, there is the log message Feb 04 20:50:10 nixos gnome-session-f[1238]: Cannot open display: - that could be interesting. I grepped mutter, gnome-shell and gdm; but I don't know where the message is coming from.

@samdroid-apps

  1. That is conguent with my findings and it begs two questions:

    1. Why does GDM run in X even when we are setting Wayland=true?

    2. Can GDM running on X launch wayland sessions?

  2. That is probably emitted by gnome-session-failed program from gnome-session. Though the message itself might come from a different source (GTK?)

I'm getting some really weird behavior in vms. Tried reproduce manual startup from a VT, which seems to work if I use ZSH as a login shell, but not Bash which says that no schemas can be found.

After I got a manual session running I was able to login with GDM (you want to add gnome3.gnome_session to system packages so you won't have to look it up in the store). Now I'm somehow stuck in a working state where GDM logs in successfully on the first try even in fresh VMs (ever after deleting the .qcow2 images). So yeah, weird.

To switch VTs in qemu you can use ctrl-alt-2 to switch to the qemu console where you can use sendkey ctrl-alt-f1 to switch VTs: askubuntu answer

I'm basically using the configuration.nix that @jtojnar posted, but installed gnome-session and couldn't use the memory thing, (-m 1500 when running the VMs worked though):

{ pkgs, config, ... }:
{
  environment.systemPackages = with pkgs; [
    gdb
    binutils # readelf
    rr
    file
    tree
    htop
    less
    dbus
    dfeet
    gnome3.gnome_session
  ];

  services.openssh.enable = true;
  hardware.pulseaudio.enable = false; # some x11-publish errors
  boot.cleanTmpDir = true;

  # add debugging symbols
  environment.enableDebugInfo = true;
  nixpkgs.config.packageOverrides = super: {
    gnome3 = super.gnome3 // {
      gdm = super.enableDebugging super.gnome3.gdm;
    };
  };

  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleUseXkbConfig = true;
    defaultLocale = "en_DK.UTF-8";
  };

  services.xserver = {
    enable = true;
    layout = "us";
    xkbVariant = "dvp";
    xkbOptions = "caps:swapescape,altwin:swap_lalt_lwin,lv3:ralt_switch";

    desktopManager = {
      gnome3.enable = true;
    };

    displayManager = {
      gdm.enable = true;
      gdm.autoLogin.enable = false;
      gdm.debug = true;
    };
  };

  users.extraUsers.hed = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" "networkmanager" ];
    password = "";
    openssh.authorizedKeys.keys = [
...
    ];
  };

  systemd.coredump.enable = true;
  # virtualisation.memorySize = 1024;
}

It might be worth trying to remove any lingering /tmp/.X11-unix/X* sockets. After doing that I'm able to log in with GDM, though had to try 2-3 times. This is outside of a vm, using the wayland-tryouts branch with the TYPE=Application change on top.

What's the latest here? Is anyone using GNOME + Wayland as a daily driver?

@colemickens the way we launch sessions from the display manager makes launching wayland sessions hard, so there's a few changes that needs to be made first, see eg. https://github.com/NixOS/nixpkgs/issues/39871

@colemickens I am running gnome+wayland, though not from GDM, but started manually like that:
[run_gnome_session.nixsh]

#! /usr/bin/env nix-shell
#! nix-shell -p glib.dev -i bash
XDG_SESSION_TYPE=wayland dbus-run-session $(nix-build '<nixpkgs>' -A gnome3.gnome_session)/bin/gnome-session

[.profile]

if [[ `tty` = /dev/tty1 ]]
then
    while true
    do  
        echo "=========================== STARTING GNOME SHELL ================================="
        /home/balsoft/run_gnome_session.nixsh
        echo "=========================== EXITING GNOME SHELL =================================="
    done
fi

It only partially works for me. Somehow it breaks my shell (locale or something? I'll post a screenshot later). It also seems to break gpg-agent somehow (and it's not the usual gnome-keyring thing), maybe due to it not getting a valid loginctl session?

What needs to happen to NixOS to support Wayland sessions?

There's WIP PR for gome wayland support now #44497 for people who want to test it out :)

Thanks to great work by @hedning, GNOME now supports Wayland by default.

Just the following should be enough:

{
  services.xserver = {
    enable = true;

    displayManager.gdm = {
      enable = true;
    };

    desktopManager.gnome3 = {
      enable = true;
    };
  };
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ob7 picture ob7  ·  3Comments

yawnt picture yawnt  ·  3Comments

grahamc picture grahamc  ·  3Comments

retrry picture retrry  ·  3Comments

tomberek picture tomberek  ·  3Comments