-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ydotool: refactor ; nixos/ydotool: init module & nixosTest #303745
Conversation
oh man i should've looked before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to get this in, because it'll allow for mouse control in Wayland tests. I've tried this out for Lomiri, and it lets me test some keyboard-unreachable elements.
I really don't feel qualified to judge the correctness of all those service settings however…
@alois31 you added the systemd hardening options on my rimgo module pr so you seem to know some stuff, do you want to review the hardening on this module? |
TBH I just slapped every hardening option that |
Maybe a VM test could be written to verify that the module works as expected? Just loading up a WM or app, using the tool to click on something and verifying via console output / pgrep / OCR that something actually happened. |
I have not written a VM test yet, so I will have to read a bit of docs first, but it seems like a good idea. |
@OPNA2608 do you have an idea how i could check ydotools keypresses reliably? |
oh wait you think i should do something in a graphical environment? |
For example yeah (sorry, typo'd earlier). Like using ydotool to click on a starter menu and checking with OCR if any of its contents are displayed. Or just a tty session, sending the inputs for |
I used the same approach as you did here, and I'm not familiar with ydotool, so I don't think I can be of any help. |
another idea i had was directly |
I was thinking something like this: Test file
import ./make-test-python.nix ({ pkgs, lib, ... }: let
textInput = "This works.";
in {
name = "ydotool";
meta = {
maintainers = with lib.maintainers; [ OPNA2608 quantenzitrone ];
};
nodes = {
headless = { config, ... }: {
imports = [
./common/user-account.nix
];
users.users.alice.extraGroups = [ "ydotool" ];
programs.ydotool.enable = true;
services.getty.autologinUser = "alice";
};
x11 = { config, ... }: {
imports = [
./common/user-account.nix
./common/auto.nix
./common/x11.nix
];
users.users.alice.extraGroups = [ "ydotool" ];
programs.ydotool.enable = true;
test-support.displayManager.auto = {
enable = true;
user = "alice";
};
services.xserver.windowManager.dwm.enable = true;
services.displayManager.defaultSession = lib.mkForce "none+dwm";
environment = {
etc."gui-text".text = textInput;
systemPackages = with pkgs; [ gnome.zenity ];
};
};
wayland = { config, ... }: {
imports = [
./common/user-account.nix
./common/auto.nix
./common/x11.nix
];
users.users.alice.extraGroups = [ "ydotool" ];
programs.ydotool.enable = true;
test-support.displayManager.auto = {
enable = true;
user = "alice";
};
programs.miriway.enable = true;
services.displayManager.defaultSession = lib.mkForce "miriway";
environment = {
etc."gui-text".text = textInput;
systemPackages = with pkgs; [ gnome.zenity ];
};
};
};
enableOCR = true;
testScript = { nodes, ... }: ''
def as_user(cmd: str):
"""
Return a shell command for running a shell command as a specific user.
"""
return f"sudo -u alice -i {cmd}"
def ask_for_input():
"""
Return a command to spawn a window that asks for input. The input will be sent to /tmp/output.
"""
return as_user("zenity --entry --text 'Enter input:' > /tmp/output &")
start_all()
# Headless
headless.wait_for_unit("multi-user.target")
headless.wait_for_text("alice")
headless.succeed(as_user("ydotool type 'echo ${textInput} > /tmp/output'")) # text input
headless.succeed(as_user("ydotool key 28:1 28:0")) # text input
headless.screenshot("headless_input")
headless.wait_for_file("/tmp/output")
headless.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
# X11
x11.wait_for_x()
x11.execute(ask_for_input())
x11.wait_for_text("Enter input")
x11.succeed(as_user("ydotool type -f /etc/gui-text")) # text input
x11.screenshot("x11_input")
x11.succeed(as_user("ydotool mousemove -a 400 110")) # mouse input
x11.succeed(as_user("ydotool click 0xC0")) # mouse input
x11.wait_for_file("/tmp/output")
x11.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
# Wayland
wayland.wait_for_x()
wayland.execute(ask_for_input())
wayland.wait_for_text("Enter input")
wayland.succeed(as_user("ydotool type -f /etc/gui-text")) # text input
wayland.screenshot("wayland_input")
wayland.succeed(as_user("ydotool mousemove -a 350 200")) # mouse input
wayland.succeed(as_user("ydotool click 0xC0")) # mouse input
wayland.wait_for_file("/tmp/output")
wayland.wait_until_succeeds("grep '${textInput}' /tmp/output") # text input
'';
}) + a corresponding entry in This tests keyboard functionality on tty, X11 & Wayland, and mouse functionality on X11 & Wayland. |
@quantenzitrone Bump on the test situation/question, plus there's a changelog merge conflict that needs to be resolved. |
Sorry for stalling this so long. |
No problem!
A major dependency of it is currently broken by staging fallout: #310091
A kiosk-like compositor like cage seems like a better fit anyway, so it's fine. |
Using the
Seems to fail on this setting: nixpkgs/nixos/tests/common/wayland-cage.nix Lines 10 to 12 in 01b405c
You could try messing with overriding this setting in the test (I don't know why it's there, maybe it's not needed anymore?), or setting up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still don't know what all those service settings do, but if systemd thinks it's good & the service still works fine in the VM test, then it can't be completely wrong. LGTM.
I mean, if you want to understand the options, you could read the relevant parts of the systemd.exec(5) and systemd.resource-contro(5) man pages. |
(Merge conflict on release notes again) |
Co-authored-by: Cosima Neidahl <[email protected]>
Co-authored-by: Cosima Neidahl <[email protected]>
(i forgor that i have to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Added a finishing dot to the release notes entry myself, for consistency with the other entries. Just so we don't need another back n forth for such a nit)
Description of changes
closes #183659
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.