Merge pull request #44497 from hedning/gnome-upstream-wayland

Add gnome wayland support
This commit is contained in:
Tor Hedin Brønner 2018-12-10 16:53:27 +01:00 committed by GitHub
commit 59d1fb6151
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 27 deletions

View file

@ -136,19 +136,17 @@ in {
services.xserver.displayManager.extraSessionFilePackages = [ pkgs.gnome3.gnome-session ];
services.xserver.displayManager.sessionCommands = ''
if test "$XDG_CURRENT_DESKTOP" = "GNOME"; then
${concatMapStrings (p: ''
if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
fi
environment.extraInit = ''
${concatMapStrings (p: ''
if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
fi
if [ -d "${p}/lib/girepository-1.0" ]; then
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}
fi
if [ -d "${p}/lib/girepository-1.0" ]; then
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}
'';
environment.variables.GNOME_SESSION_DEBUG = optionalString cfg.debug "1";

View file

@ -78,8 +78,7 @@ let
# 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.
# FIXME: Check XDG_SESSION_TYPE against x11
# Load X defaults. This should probably be safe on wayland too.
${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
if test -e ~/.Xresources; then
${xorg.xrdb}/bin/xrdb -merge ~/.Xresources
@ -194,6 +193,11 @@ let
${concatMapStrings (pkg: ''
${xorg.lndir}/bin/lndir ${pkg}/share/xsessions $out/share/xsessions
'') cfg.displayManager.extraSessionFilePackages}
mkdir -p "$out/share/wayland-sessions"
${concatMapStrings (pkg: ''
${xorg.lndir}/bin/lndir ${pkg}/share/wayland-sessions $out/share/wayland-sessions
'') cfg.displayManager.extraSessionFilePackages}
'';
in
@ -240,7 +244,10 @@ in
''
xmessage "Hello World!" &
'';
description = "Shell commands executed just before the window or desktop manager is started.";
description = ''
Shell commands executed just before the window or desktop manager is
started. These commands are not currently sourced for Wayland sessions.
'';
};
hiddenUsers = mkOption {

View file

@ -59,6 +59,7 @@ let
[Wayland]
EnableHidpi=${if cfg.enableHidpi then "true" else "false"}
SessionDir=${dmcfg.session.desktops}/share/wayland-sessions
${optionalString cfg.autoLogin.enable ''
[Autologin]

View file

@ -23,11 +23,21 @@ import ./make-test.nix ({ pkgs, ...} : {
virtualisation.memorySize = 1024;
};
testScript =
''
# wait for gdm to start and bring up X
testScript = let
# Keep line widths somewhat managable
bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus";
gdbus = "${bus} gdbus";
# Call javascript in gnome shell, returns a tuple (success, output), where
# `success` is true if the dbus call was successful and output is what the
# javascript evaluates to.
eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval";
# False when startup is done
startingUp = "${gdbus} ${eval} Main.layoutManager._startingUp";
# Hopefully gnome-terminal's wm class
wmClass = "${gdbus} ${eval} global.display.focus_window.wm_class";
in ''
# wait for gdm to start
$machine->waitForUnit("display-manager.service");
$machine->waitForX;
# wait for alice to be logged in
$machine->waitForUnit("default.target","alice");
@ -35,10 +45,16 @@ import ./make-test.nix ({ pkgs, ...} : {
# Check that logging in has given the user ownership of devices.
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
# open a terminal and check it's there
$machine->succeed("su - alice -c 'DISPLAY=:0.0 XAUTHORITY=/run/user/\$UID/gdm/Xauthority gnome-terminal'");
$machine->succeed("xauth merge /run/user/1000/gdm/Xauthority");
$machine->waitForWindow(qr/Terminal/);
# Wait for the wayland server
$machine->waitForFile("/run/user/1000/wayland-0");
# Wait for gnome shell, correct output should be "(true, 'false')"
$machine->waitUntilSucceeds("su - alice -c '${startingUp} | grep -q true,..false'");
# open a terminal
$machine->succeed("su - alice -c '${bus} gnome-terminal'");
# and check it's there
$machine->waitUntilSucceeds("su - alice -c '${wmClass} | grep -q gnome-terminal-server'");
# wait to get a nice screenshot
$machine->sleep(20);

View file

@ -16,7 +16,7 @@ import ./make-test.nix ({ pkgs, ...} : {
services.xserver.displayManager.lightdm.autoLogin.enable = true;
services.xserver.displayManager.lightdm.autoLogin.user = "alice";
services.xserver.desktopManager.gnome3.enable = true;
services.xserver.desktopManager.default = "gnome";
services.xserver.desktopManager.default = "gnome-xorg";
virtualisation.memorySize = 1024;
};

View file

@ -1,6 +1,6 @@
{ fetchurl, stdenv, substituteAll, meson, ninja, pkgconfig, gnome3, glib, gtk, gsettings-desktop-schemas
, gnome-desktop, dbus, json-glib, libICE, xmlto, docbook_xsl, docbook_xml_dtd_412, python3
, libxslt, gettext, makeWrapper, systemd, xorg, epoxy }:
, libxslt, gettext, makeWrapper, systemd, xorg, epoxy, gnugrep, bash }:
stdenv.mkDerivation rec {
name = "gnome-session-${version}";
@ -16,6 +16,8 @@ stdenv.mkDerivation rec {
src = ./fix-paths.patch;
gsettings = "${glib.bin}/bin/gsettings";
dbusLaunch = "${dbus.lib}/bin/dbus-launch";
grep = "${gnugrep}/bin/grep";
bash = "${bash}/bin/bash";
})
];
@ -37,8 +39,11 @@ stdenv.mkDerivation rec {
patchShebangs meson_post_install.py
'';
# `bin/gnome-session` will reset the environment when run in wayland, we
# therefor wrap `libexec/gnome-session-binary` instead which is the actual
# binary needing wrapping
preFixup = ''
wrapProgram "$out/bin/gnome-session" \
wrapProgram "$out/libexec/gnome-session-binary" \
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
--suffix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
--suffix XDG_DATA_DIRS : "${gnome3.gnome-shell}/share"\

View file

@ -1,6 +1,22 @@
--- a/gnome-session/gnome-session.in
+++ b/gnome-session/gnome-session.in
@@ -13,7 +13,7 @@ if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
@@ -3,11 +3,11 @@
if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
[ "x$XDG_SESSION_CLASS" != "xgreeter" ] &&
[ -n "$SHELL" ] &&
- grep -q "$SHELL" /etc/shells &&
- ! (echo "$SHELL" | grep -q "false") &&
- ! (echo "$SHELL" | grep -q "nologin"); then
+ @grep@ -q "$SHELL" /etc/shells &&
+ ! (echo "$SHELL" | @grep@ -q "false") &&
+ ! (echo "$SHELL" | @grep@ -q "nologin"); then
if [ "$1" != '-l' ]; then
- exec bash -c "exec -l '$SHELL' -c '$0 -l $*'"
+ exec @bash@ -c "exec -l '$SHELL' -c '$0 -l $*'"
else
shift
fi
@@ -13,7 +13,7 @@
fi
fi