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) (lib.attrValues pkgs.gnomeExtensions);
15 # Some extensions are broken, but that's kind of the point of a testing VM
16 nixpkgs.config.allowBroken = true;
17 # There are some aliases which throw exceptions; ignore them.
18 # Also prevent duplicate extensions under different names.
19 nixpkgs.config.allowAliases = false;
22 services.xserver.enable = true;
23 services.xserver.displayManager = {
36 services.xserver.desktopManager.gnome.enable = true;
37 services.xserver.desktopManager.gnome.debug = true;
39 systemd.user.services = {
40 "org.gnome.Shell@wayland" = {
43 # Clear the list before overriding it.
45 # Eval API is now internal so Shell needs to run in unsafe mode.
46 # TODO: improve test driver so that it supports openqa-like manipulation
47 # that would allow us to drop this mess.
48 "${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
56 testScript = { nodes, ... }: let
57 # Keep line widths somewhat manageable
58 user = nodes.machine.users.users.alice;
59 uid = toString user.uid;
60 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
61 # Run a command in the appropriate user environment
62 run = command: "su - ${user.name} -c '${bus} ${command}'";
64 # Call javascript in gnome shell, returns a tuple (success, output), where
65 # `success` is true if the dbus call was successful and output is what the
66 # javascript evaluates to.
67 eval = command: run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
69 # False when startup is done
70 startingUp = eval "Main.layoutManager._startingUp";
72 # Extensions to keep always enabled together
73 # Those are extensions that are usually always on for many users, and that we expect to work
74 # well together with most others without conflicts
75 alwaysOnExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
80 # Extensions to enable and disable individually
81 # Extensions like dash-to-dock and dash-to-panel cannot be enabled at the same time.
82 testExtensions = map (name: pkgs.gnomeExtensions.${name}.extensionUuid) [
89 "desktop-icons-ng-ding"
95 with subtest("Login to GNOME with GDM"):
96 # wait for gdm to start
97 machine.wait_for_unit("display-manager.service")
98 # wait for the wayland server
99 machine.wait_for_file("/run/user/${uid}/wayland-0")
100 # wait for alice to be logged in
101 machine.wait_for_unit("default.target", "${user.name}")
102 # check that logging in has given the user ownership of devices
103 assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
105 with subtest("Wait for GNOME Shell"):
106 # correct output should be (true, 'false')
107 machine.wait_until_succeeds(
108 "${startingUp} | grep -q 'true,..false'"
111 # Close the Activities view so that Shell can correctly track the focused window.
112 machine.send_key("esc")
113 # # Disable extension version validation (only use for manual testing)
115 # "${run "gsettings set org.gnome.shell disable-extension-version-validation true"}"
118 # Assert that some extension is in a specific state
119 def checkState(target, extension):
120 state = machine.succeed(
121 f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
123 assert target in state, f"{state} instead of {target}"
125 def checkExtension(extension, disable):
126 with subtest(f"Enable extension '{extension}'"):
127 # Check that the extension is properly initialized; skip out of date ones
128 state = machine.succeed(
129 f"${run "gnome-extensions info {extension}"} | grep '^ State: .*$'"
131 if "OUT OF DATE" in state:
132 machine.log(f"Extension {extension} will be skipped because out of date")
135 assert "INITIALIZED" in state, f"{state} instead of INITIALIZED"
137 # Enable and optionally disable
139 machine.succeed(f"${run "gnome-extensions enable {extension}"}")
140 checkState("ACTIVE", extension)
143 machine.succeed(f"${run "gnome-extensions disable {extension}"}")
144 checkState("INACTIVE", extension)
146 + lib.concatLines (map (e: ''checkExtension("${e}", False)'') alwaysOnExtensions)
147 + lib.concatLines (map (e: ''checkExtension("${e}", True)'') testExtensions)