1{ pkgs, lib, ... }:
2{
3 name = "cinnamon";
4
5 meta.maintainers = lib.teams.cinnamon.members;
6
7 nodes.machine =
8 { ... }:
9 {
10 imports = [ ./common/user-account.nix ];
11 services.xserver.enable = true;
12 services.xserver.desktopManager.cinnamon.enable = true;
13
14 # We don't ship gnome-text-editor in Cinnamon module, we add this line mainly
15 # to catch eval issues related to this option.
16 environment.cinnamon.excludePackages = [ pkgs.gnome-text-editor ];
17
18 # For the sessionPath subtest.
19 services.xserver.desktopManager.cinnamon.sessionPath = [ pkgs.gpaste ];
20
21 # For OCR test.
22 services.xserver.displayManager.lightdm.greeters.slick.extraConfig = ''
23 enable-hidpi = on
24 '';
25 };
26
27 enableOCR = true;
28
29 testScript =
30 { nodes, ... }:
31 let
32 user = nodes.machine.users.users.alice;
33 env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0";
34 su = command: "su - ${user.name} -c '${env} ${command}'";
35
36 # Call javascript in cinnamon (the shell), returns a tuple (success, output),
37 # where `success` is true if the dbus call was successful and `output` is what
38 # the javascript evaluates to.
39 eval =
40 name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}";
41 in
42 ''
43 machine.wait_for_unit("display-manager.service")
44
45 with subtest("Test if we can see username in slick-greeter"):
46 machine.wait_for_text("${user.description}")
47 machine.screenshot("slick_greeter_lightdm")
48
49 with subtest("Login with slick-greeter"):
50 machine.send_chars("${user.password}\n")
51 machine.wait_for_x()
52 machine.wait_for_file("${user.home}/.Xauthority")
53 machine.succeed("xauth merge ${user.home}/.Xauthority")
54
55 with subtest("Check that logging in has given the user ownership of devices"):
56 machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
57
58 with subtest("Wait for the Cinnamon shell"):
59 # Correct output should be (true, '2')
60 # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187
61 machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'")
62
63 with subtest("Check if Cinnamon components actually start"):
64 for i in ["csd-media-keys", "cinnamon-killer-daemon", "xapp-sn-watcher", "nemo-desktop"]:
65 machine.wait_until_succeeds(f"pgrep -f {i}")
66 machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'")
67 machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'")
68
69 with subtest("Check if sessionPath option actually works"):
70 machine.succeed("${eval "imports.gi.GIRepository.Repository.get_search_path\\(\\)"} | grep gpaste")
71
72 with subtest("Check if various environment variables are set"):
73 cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf /run/current-system/sw/bin/nemo-desktop)/environ"
74 machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'x11'")
75 machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
76 # From the nixos/cinnamon module
77 machine.succeed(f"{cmd} | grep 'SSH_AUTH_SOCK' | grep 'gcr'")
78
79 with subtest("Open Cinnamon Settings"):
80 machine.succeed("${su "cinnamon-settings themes >&2 &"}")
81 machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'")
82 machine.wait_for_text('(Style|Appearance|Color)')
83 machine.sleep(2)
84 machine.screenshot("cinnamon_settings")
85
86 with subtest("Lock the screen"):
87 machine.succeed("${su "cinnamon-screensaver-command -l >&2 &"}")
88 machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is active'")
89 machine.sleep(2)
90 machine.screenshot("cinnamon_screensaver")
91 machine.send_chars("${user.password}\n", delay=0.2)
92 machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is inactive'")
93 machine.sleep(2)
94
95 with subtest("Open GNOME Terminal"):
96 machine.succeed("${su "gnome-terminal"}")
97 machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'")
98 machine.sleep(2)
99
100 with subtest("Open virtual keyboard"):
101 machine.succeed("${su "dbus-send --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.ToggleKeyboard"}")
102 machine.wait_for_text('(Ctrl|Alt)')
103 machine.sleep(2)
104 machine.screenshot("cinnamon_virtual_keyboard")
105
106 with subtest("Check if Cinnamon has ever coredumped"):
107 machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'")
108 '';
109}