2 system ? builtins.currentSystem,
4 pkgs ? import ../.. { inherit system config; },
8 makeTest = import ./make-test-python.nix;
9 textInput = "This works.";
10 inputBoxText = "Enter input";
11 inputBox = pkgs.writeShellScript "zenity-input" ''
12 ${lib.getExe pkgs.zenity} --entry --text '${inputBoxText}:' > /tmp/output &
15 def as_user(cmd: str):
17 Return a shell command for running a shell command as a specific user.
19 return f"sudo -u alice -i {cmd}"
29 imports = [ ./common/user-account.nix ];
31 users.users.alice.extraGroups = [ "ydotool" ];
33 programs.ydotool.enable = true;
35 services.getty.autologinUser = "alice";
43 machine.wait_for_unit("multi-user.target")
44 machine.wait_for_text("alice")
45 machine.succeed(as_user("ydotool type 'echo ${textInput} > /tmp/output'")) # text input
46 machine.succeed(as_user("ydotool key 28:1 28:0")) # text input
47 machine.screenshot("headless_input")
48 machine.wait_for_file("/tmp/output")
49 machine.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
52 meta.maintainers = with lib.maintainers; [
65 ./common/user-account.nix
70 users.users.alice.extraGroups = [ "ydotool" ];
72 programs.ydotool.enable = true;
74 test-support.displayManager.auto = {
79 services.xserver.windowManager.dwm.enable = true;
80 services.displayManager.defaultSession = lib.mkForce "none+dwm";
89 machine.execute(as_user("${inputBox}"))
90 machine.wait_for_text("${inputBoxText}")
91 machine.succeed(as_user("ydotool type '${textInput}'")) # text input
92 machine.screenshot("x11_input")
93 machine.succeed(as_user("ydotool mousemove -a 400 110")) # mouse input
94 machine.succeed(as_user("ydotool click 0xC0")) # mouse input
95 machine.wait_for_file("/tmp/output")
96 machine.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
99 meta.maintainers = with lib.maintainers; [
111 imports = [ ./common/user-account.nix ];
118 programs.ydotool.enable = true;
120 services.cage.program = inputBox;
126 machine.wait_for_unit("graphical.target")
127 machine.wait_for_text("${inputBoxText}")
128 machine.succeed("ydotool type '${textInput}'") # text input
129 machine.screenshot("wayland_input")
130 machine.succeed("ydotool mousemove -a 100 100") # mouse input
131 machine.succeed("ydotool click 0xC0") # mouse input
132 machine.wait_for_file("/tmp/output")
133 machine.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
136 meta.maintainers = with lib.maintainers; [
144 name = "customGroup";
145 nodeName = "${name}Node";
146 insideGroupUsername = "ydotool-user";
147 outsideGroupUsername = "other-user";
148 groupName = "custom-group";
153 nodes."${nodeName}" = {
160 "${insideGroupUsername}" = {
162 extraGroups = [ groupName ];
164 "${outsideGroupUsername}".isNormalUser = true;
171 # Wait for service to start
172 ${nodeName}.wait_for_unit("multi-user.target")
173 ${nodeName}.wait_for_unit("ydotoold.service")
175 # Verify that user with the configured group can use the service
176 ${nodeName}.succeed("sudo --login --user=${insideGroupUsername} ydotool type 'Hello, World!'")
178 # Verify that user without the configured group can't use the service
179 ${nodeName}.fail("sudo --login --user=${outsideGroupUsername} ydotool type 'Hello, World!'")
182 meta.maintainers = with lib.maintainers; [ l0b0 ];