1{ pkgs, lib, ... }:
2
3{
4 name = "pantheon";
5
6 meta.maintainers = lib.teams.pantheon.members;
7
8 nodes.machine =
9 { ... }:
10
11 let
12 videosAutostart = pkgs.writeTextFile {
13 name = "autostart-elementary-videos";
14 destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
15 text = ''
16 [Desktop Entry]
17 Version=1.0
18 Name=Videos
19 Type=Application
20 Terminal=false
21 Exec=io.elementary.videos %U
22 '';
23 };
24 in
25 {
26 imports = [ ./common/user-account.nix ];
27
28 # Workaround ".gala-wrapped invoked oom-killer"
29 virtualisation.memorySize = 2047;
30
31 services.xserver.enable = true;
32 services.desktopManager.pantheon.enable = true;
33
34 # We ship pantheon.appcenter by default when this is enabled.
35 services.flatpak.enable = true;
36
37 # For basic OCR tests.
38 environment.systemPackages = [ videosAutostart ];
39
40 # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
41 # to catch eval issues related to this option.
42 environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
43
44 programs.ydotool.enable = true;
45 };
46
47 enableOCR = true;
48
49 testScript =
50 { nodes, ... }:
51 let
52 user = nodes.machine.users.users.alice;
53 in
54 ''
55 machine.wait_for_unit("display-manager.service")
56
57 with subtest("Test we can see usernames in elementary-greeter"):
58 machine.wait_for_text("${user.description}")
59 machine.wait_until_succeeds("pgrep -f io.elementary.greeter-compositor")
60 # Ensure the password box is focused by clicking it.
61 # Workaround for https://github.com/NixOS/nixpkgs/issues/211366.
62 machine.succeed("ydotool mousemove -a 220 275")
63 machine.succeed("ydotool click 0xC0")
64 machine.sleep(2)
65 machine.screenshot("elementary_greeter_lightdm")
66
67 with subtest("Login with elementary-greeter"):
68 machine.send_chars("${user.password}\n")
69 machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
70
71 with subtest("Wait for wayland server"):
72 machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
73
74 with subtest("Check that logging in has given the user ownership of devices"):
75 machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
76
77 with subtest("Check if Pantheon components actually start"):
78 pgrep_list = [
79 "${pkgs.pantheon.gala}/bin/gala",
80 "io.elementary.wingpanel",
81 "io.elementary.dock",
82 "${pkgs.pantheon.gnome-settings-daemon}/libexec/gsd-media-keys",
83 # We specifically check gsd-xsettings here since it is manually pulled up by gala.
84 # https://github.com/elementary/gala/pull/2140
85 "${pkgs.pantheon.gnome-settings-daemon}/libexec/gsd-xsettings",
86 "${pkgs.pantheon.pantheon-agent-polkit}/libexec/policykit-1-pantheon/io.elementary.desktop.agent-polkit",
87 "${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal"
88 ]
89 for i in pgrep_list:
90 machine.wait_until_succeeds(f"pgrep -xf {i}")
91
92 with subtest("Check if various environment variables are set"):
93 cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
94 machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
95 machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
96 # Hopefully from the sessionPath option.
97 machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
98 # Hopefully from login shell.
99 machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
100 # Hopefully from gcr-ssh-agent.
101 machine.succeed(f"{cmd} | grep 'SSH_AUTH_SOCK' | grep 'gcr'")
102
103 with subtest("Wait for elementary videos autostart"):
104 machine.wait_until_succeeds("pgrep -xf /run/current-system/sw/bin/io.elementary.videos")
105 machine.wait_for_text("No Videos Open")
106 machine.screenshot("videos")
107
108 with subtest("Trigger multitasking view"):
109 cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
110 env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
111 machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
112 machine.sleep(5)
113 machine.screenshot("multitasking")
114 machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
115
116 with subtest("Check if gala has ever coredumped"):
117 machine.fail("coredumpctl --json=short | grep gala")
118 # So we can see the dock.
119 machine.execute("pkill -f -9 io.elementary.videos")
120 machine.sleep(10)
121 machine.screenshot("screen")
122 '';
123}