|
3 | 3 | name = "monado"; |
4 | 4 |
|
5 | 5 | nodes.machine = |
6 | | - { pkgs, ... }: |
| 6 | + { |
| 7 | + lib, |
| 8 | + pkgs, |
| 9 | + config, |
| 10 | + ... |
| 11 | + }: |
7 | 12 |
|
8 | 13 | { |
9 | | - hardware.graphics.enable = true; |
10 | | - users.users.alice = { |
11 | | - isNormalUser = true; |
12 | | - uid = 1000; |
| 14 | + imports = [ ./common/openxr.nix ]; |
| 15 | + |
| 16 | + systemd.user.services.print-openxr-info = { |
| 17 | + wantedBy = [ "xdg-desktop-autostart.target" ]; |
| 18 | + requires = [ "monado.service" ]; |
| 19 | + script = lib.getExe' pkgs.openxr-loader "openxr_runtime_list"; |
| 20 | + serviceConfig = { |
| 21 | + Type = "oneshot"; |
| 22 | + RemainAfterExit = true; |
| 23 | + }; |
13 | 24 | }; |
14 | 25 |
|
15 | | - services.monado = { |
16 | | - enable = true; |
17 | | - defaultRuntime = true; |
18 | | - |
19 | | - forceDefaultRuntime = true; |
| 26 | + systemd.user.services.xrgears = { |
| 27 | + wantedBy = [ "xdg-desktop-autostart.target" ]; |
| 28 | + requires = [ "monado.service" ]; |
| 29 | + script = lib.getExe pkgs.xrgears; |
20 | 30 | }; |
21 | | - # Stop Monado from probing for any hardware |
22 | | - systemd.user.services.monado.environment.SIMULATED_ENABLE = "1"; |
23 | | - |
24 | | - environment.systemPackages = with pkgs; [ openxr-loader ]; |
25 | 31 | }; |
26 | 32 |
|
27 | 33 | testScript = |
28 | 34 | { nodes, ... }: |
29 | | - let |
30 | | - userId = toString nodes.machine.users.users.alice.uid; |
31 | | - runtimePath = "/run/user/${userId}"; |
32 | | - in |
33 | 35 | '' |
34 | | - # for defaultRuntime |
35 | | - machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json") |
36 | | -
|
37 | | - machine.succeed("loginctl enable-linger alice") |
38 | | - machine.wait_for_unit("user@${userId}.service") |
39 | | -
|
40 | | - machine.wait_for_unit("monado.socket", "alice") |
41 | | - machine.systemctl("start monado.service", "alice") |
42 | | - machine.wait_for_unit("monado.service", "alice") |
43 | | -
|
44 | | - # for forceDefaultRuntime |
45 | | - machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json") |
46 | | -
|
47 | | - machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list") |
| 36 | + with subtest("Ensure X11 starts"): |
| 37 | + start_all() |
| 38 | + machine.succeed("loginctl enable-linger alice") |
| 39 | + machine.wait_for_x() |
| 40 | +
|
| 41 | + with subtest("Ensure default runtime present"): |
| 42 | + machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json") |
| 43 | +
|
| 44 | + with subtest("Ensure forced runtime present"): |
| 45 | + # Monado needs to be started to create the forced runtime file |
| 46 | + machine.systemctl("start monado.service", "alice") |
| 47 | + machine.wait_for_unit("monado.service", "alice") |
| 48 | + machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json") |
| 49 | +
|
| 50 | + with subtest("Ensure openxr_runtime_list can find runtime"): |
| 51 | + machine.wait_for_unit("print-openxr-info.service", "alice") |
| 52 | +
|
| 53 | + with subtest("Ensure xrgears launches"): |
| 54 | + machine.wait_for_unit("xrgears.service", "alice") |
| 55 | + # TODO: 10 seconds should be long enough for anything, but this is theoretically flaky |
| 56 | + machine.sleep(10) |
| 57 | + machine.screenshot("screen") |
48 | 58 | ''; |
49 | 59 | } |
0 commit comments