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