1{ pkgs, lib, ... }:
2{
3 name = "gnome-xorg";
4 meta = {
5 maintainers = lib.teams.gnome.members;
6 };
7
8 nodes.machine =
9 { nodes, ... }:
10 let
11 user = nodes.machine.users.users.alice;
12 in
13
14 {
15 imports = [ ./common/user-account.nix ];
16
17 services.xserver.enable = true;
18
19 services.displayManager.gdm = {
20 enable = true;
21 debug = true;
22 };
23
24 services.displayManager.autoLogin = {
25 enable = true;
26 user = user.name;
27 };
28
29 services.desktopManager.gnome.enable = true;
30 services.desktopManager.gnome.debug = true;
31 services.displayManager.defaultSession = "gnome-xorg";
32
33 systemd.user.services = {
34 "org.gnome.Shell@x11" = {
35 serviceConfig = {
36 ExecStart = [
37 # Clear the list before overriding it.
38 ""
39 # Eval API is now internal so Shell needs to run in unsafe mode.
40 # TODO: improve test driver so that it supports openqa-like manipulation
41 # that would allow us to drop this mess.
42 "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
43 ];
44 };
45 };
46 };
47
48 };
49
50 testScript =
51 { nodes, ... }:
52 let
53 user = nodes.machine.users.users.alice;
54 uid = toString user.uid;
55 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
56 xauthority = "/run/user/${uid}/gdm/Xauthority";
57 display = "DISPLAY=:0.0";
58 env = "${bus} XAUTHORITY=${xauthority} ${display}";
59 # Run a command in the appropriate user environment
60 run = command: "su - ${user.name} -c '${bus} ${command}'";
61
62 # Call javascript in gnome shell, returns a tuple (success, output), where
63 # `success` is true if the dbus call was successful and output is what the
64 # javascript evaluates to.
65 eval =
66 command:
67 run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
68
69 # False when startup is done
70 startingUp = eval "Main.layoutManager._startingUp";
71
72 # Start Console
73 launchConsole = run "gapplication launch org.gnome.Console";
74
75 # Hopefully Console's wm class
76 wmClass = eval "global.display.focus_window.wm_class";
77 in
78 ''
79 with subtest("Login to GNOME Xorg with GDM"):
80 machine.wait_for_x()
81 # Wait for alice to be logged in"
82 machine.wait_for_unit("default.target", "${user.name}")
83 machine.wait_for_file("${xauthority}")
84 machine.succeed("xauth merge ${xauthority}")
85 # Check that logging in has given the user ownership of devices
86 assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
87
88 with subtest("Wait for GNOME Shell"):
89 # correct output should be (true, 'false')
90 machine.wait_until_succeeds(
91 "${startingUp} | grep -q 'true,..false'"
92 )
93
94 with subtest("Open Console"):
95 # Close the Activities view so that Shell can correctly track the focused window.
96 machine.send_key("esc")
97
98 machine.succeed(
99 "${launchConsole}"
100 )
101 # correct output should be (true, '"kgx"')
102 # For some reason, this deviates from Wayland.
103 machine.wait_until_succeeds(
104 "${wmClass} | grep -q 'true,...kgx'"
105 )
106 machine.sleep(20)
107 machine.screenshot("screen")
108 '';
109}