1 import ./make-test-python.nix (
4 name = "gnome-extensions";
5 meta.maintainers = [ ];
10 imports = [ ./common/user-account.nix ];
12 # Install all extensions
13 environment.systemPackages = lib.filter (e: e ? extensionUuid) (
14 lib.attrValues pkgs.gnomeExtensions
17 # Some extensions are broken, but that's kind of the point of a testing VM
18 nixpkgs.config.allowBroken = true;
19 # There are some aliases which throw exceptions; ignore them.
20 # Also prevent duplicate extensions under different names.
21 nixpkgs.config.allowAliases = false;
24 services.xserver.enable = true;
25 services.xserver.displayManager = {
38 services.xserver.desktopManager.gnome.enable = true;
39 services.xserver.desktopManager.gnome.debug = true;
41 systemd.user.services = {
42 "org.gnome.Shell@wayland" = {
45 # Clear the list before overriding it.
47 # Eval API is now internal so Shell needs to run in unsafe mode.
48 # TODO: improve test driver so that it supports openqa-like manipulation
49 # that would allow us to drop this mess.
50 "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
61 # Keep line widths somewhat manageable
62 user = nodes.machine.users.users.alice;
63 uid = toString user.uid;
64 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
65 # Run a command in the appropriate user environment
66 run = command: "su - ${user.name} -c '${bus} ${command}'";
68 # Call javascript in gnome shell, returns a tuple (success, output), where
69 # `success` is true if the dbus call was successful and output is what the
70 # javascript evaluates to.
73 run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
75 # False when startup is done
76 startingUp = eval "Main.layoutManager._startingUp";
78 # Extensions to keep always enabled together
79 # Those are extensions that are usually always on for many users, and that we expect to work
80 # well together with most others without conflicts
81 alwaysOnExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
86 # Extensions to enable and disable individually
87 # Extensions like dash-to-dock and dash-to-panel cannot be enabled at the same time.
88 testExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
95 "desktop-icons-ng-ding"
101 with subtest("Login to GNOME with GDM"):
102 # wait for gdm to start
103 machine.wait_for_unit("display-manager.service")
104 # wait for the wayland server
105 machine.wait_for_file("/run/user/${uid}/wayland-0")
106 # wait for alice to be logged in
107 machine.wait_for_unit("default.target", "${user.name}")
108 # check that logging in has given the user ownership of devices
109 assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
111 with subtest("Wait for GNOME Shell"):
112 # correct output should be (true, 'false')
113 machine.wait_until_succeeds(
114 "${startingUp} | grep -q 'true,..false'"
117 # Close the Activities view so that Shell can correctly track the focused window.
118 machine.send_key("esc")
119 # # Disable extension version validation (only use for manual testing)
121 # "${run "gsettings set org.gnome.shell disable-extension-version-validation true"}"
124 # Assert that some extension is in a specific state
125 def checkState(target, extension):
126 state = machine.succeed(
127 f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
129 assert target in state, f"{state} instead of {target}"
131 def checkExtension(extension, disable):
132 with subtest(f"Enable extension '{extension}'"):
133 # Check that the extension is properly initialized; skip out of date ones
134 state = machine.succeed(
135 f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
137 if "OUT OF DATE" in state:
138 machine.log(f"Extension {extension} will be skipped because out of date")
141 assert "INITIALIZED" in state, f"{state} instead of INITIALIZED"
143 # Enable and optionally disable
145 machine.succeed(f"${run "gnome-extensions enable {extension}"}")
146 checkState("ACTIVE", extension)
149 machine.succeed(f"${run "gnome-extensions disable {extension}"}")
150 checkState("INACTIVE", extension)
152 + lib.concatLines (map (e: ''checkExtension("${e}", False)'') alwaysOnExtensions)
153 + lib.concatLines (map (e: ''checkExtension("${e}", True)'') testExtensions);