Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:16:08.606Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

a11y.nix

297 lines · 8.0 KB · text
1# NixOS VM integration test for GPUI AccessKit (X11).
2#
3# Interactive use:
4#   nix run .#checks.x86_64-linux.a11y-test.driverInteractive
5#
6# Then in the Python REPL:
7#   start_all()
8#   machine.wait_for_x()
9#   machine.succeed("su - user -c 'DISPLAY=:0 gpui-a11y-example &'")
10#
11# Automated run:
12#   nix build .#checks.x86_64-linux.a11y-test
13{
14  pkgs,
15  inputs,
16}:
17let
18  lib = pkgs.lib;
19
20  rustBin = inputs.rust-overlay.lib.mkRustBin { } pkgs;
21  rustToolchain = rustBin.fromRustupToolchainFile ../../rust-toolchain.toml;
22  craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
23
24  gpui-a11y-example =
25    let
26      src = builtins.path {
27        path = ../../.;
28        filter =
29          path: type:
30          let
31            root = toString ../../. + "/";
32            relPath = lib.removePrefix root path;
33            firstComp = builtins.head (lib.path.subpath.components relPath);
34          in
35          builtins.elem firstComp [
36            "crates"
37            "assets"
38            "extensions"
39            "script"
40            "tooling"
41            "Cargo.toml"
42            ".config"
43            ".cargo"
44          ];
45        name = "gpui-a11y-source";
46      };
47      commonArgs = {
48        pname = "gpui-a11y-example";
49        version = "0.0.0";
50        inherit src;
51        cargoLock = ../../Cargo.lock;
52        cargoExtraArgs = "-p gpui --example a11y --locked --features=gpui_platform/runtime_shaders";
53        CARGO_PROFILE = "dev";
54
55        nativeBuildInputs = with pkgs; [
56          cmake
57          pkg-config
58          rustPlatform.bindgenHook
59        ];
60
61        buildInputs = with pkgs; [
62          fontconfig
63          freetype
64          openssl
65          zlib
66          zstd
67          alsa-lib
68          libxkbcommon
69          wayland
70          vulkan-loader
71          libglvnd
72          libx11
73          libxcb
74          libdrm
75          libgbm
76          libxcomposite
77          libxdamage
78          libxext
79          libxfixes
80          libxrandr
81        ];
82
83        cargoVendorDir = craneLib.vendorCargoDeps {
84          inherit src;
85          cargoLock = ../../Cargo.lock;
86        };
87
88        env = {
89          ZSTD_SYS_USE_PKG_CONFIG = true;
90          FONTCONFIG_FILE = pkgs.makeFontsConf {
91            fontDirectories = [
92              ../../assets/fonts/lilex
93              ../../assets/fonts/ibm-plex-sans
94            ];
95          };
96        };
97
98        doCheck = false;
99
100        stdenv =
101          let
102            base = pkgs.llvmPackages.stdenv;
103            addBinTools = old: {
104              cc = old.cc.override {
105                inherit (pkgs.llvmPackages) bintools;
106              };
107            };
108          in
109          lib.pipe base [
110            (s: s.override addBinTools)
111            pkgs.stdenvAdapters.useMoldLinker
112          ];
113      };
114      cargoArtifacts = craneLib.buildDepsOnly commonArgs;
115    in
116    craneLib.buildPackage (
117      lib.recursiveUpdate commonArgs {
118        inherit cargoArtifacts;
119        dontUseCmakeConfigure = true;
120
121        installPhase = ''
122          runHook preInstall
123          mkdir -p $out/bin
124          cp target/debug/examples/a11y $out/bin/gpui-a11y-example
125          runHook postInstall
126        '';
127
128        NIX_LDFLAGS = "-rpath ${
129          lib.makeLibraryPath [
130            pkgs.vulkan-loader
131            pkgs.wayland
132          ]
133        }";
134        dontPatchELF = true;
135
136        meta = {
137          description = "GPUI accessibility (AccessKit) example app";
138          platforms = lib.platforms.linux;
139        };
140      }
141    );
142
143  atspiTestScript = pkgs.writeTextFile {
144    name = "a11y-atspi-test";
145    text = builtins.readFile ./a11y_atspi_test.py;
146    destination = "/bin/a11y-atspi-test";
147    executable = true;
148    checkPhase = ''
149      ${pkgs.python3.interpreter} -m py_compile $target
150    '';
151  };
152
153  testPython = pkgs.python3.withPackages (ps: [ ps.pyatspi ps.pygobject3 ]);
154
155  giTypelibPath = lib.makeSearchPath "lib/girepository-1.0" [
156    pkgs.at-spi2-core
157    pkgs.glib
158    pkgs.gtk3
159    pkgs.gobject-introspection
160  ];
161in
162pkgs.testers.nixosTest {
163  name = "gpui-a11y-x11";
164
165  nodes.machine =
166    { pkgs, ... }:
167    {
168      imports = [ ];
169
170      # Minimal X11 desktop
171      services.xserver = {
172        enable = true;
173        desktopManager.xfce.enable = true;
174        displayManager.lightdm.enable = true;
175      };
176
177      # Auto-login so the test doesn't need to type a password
178      services.displayManager.autoLogin = {
179        enable = true;
180        user = "user";
181      };
182
183      # AT-SPI2 accessibility bus
184      services.gnome.at-spi2-core.enable = true;
185
186      # dconf + GSettings schemas required for Orca / AT-SPI
187      programs.dconf = {
188        enable = true;
189        profiles.user.databases = [
190          {
191            settings = {
192              "org/gnome/desktop/interface".toolkit-accessibility = true;
193              "org/gnome/desktop/a11y/applications".screen-reader-enabled = true;
194            };
195          }
196        ];
197      };
198
199      # Environment variables for debugging
200      environment.variables = {
201        RUST_BACKTRACE = "1";
202      };
203
204      # Start Orca automatically on login
205      systemd.user.services.orca = {
206        description = "Orca screen reader";
207        wantedBy = [ "graphical-session.target" ];
208        partOf = [ "graphical-session.target" ];
209        after = [ "graphical-session.target" ];
210        serviceConfig = {
211          ExecStart = "${pkgs.orca}/bin/orca --debug";
212          Restart = "on-failure";
213        };
214        environment = {
215          DISPLAY = ":0";
216        };
217      };
218
219      # Accessibility tools available in the VM
220      environment.systemPackages = [
221        gpui-a11y-example
222        atspiTestScript
223        testPython
224        pkgs.accerciser
225        pkgs.gsettings-desktop-schemas
226        pkgs.orca
227        pkgs.xdotool
228      ];
229
230      # Test user
231      users.users.user = {
232        isNormalUser = true;
233        password = "pass";
234        extraGroups = [ "wheel" ];
235      };
236
237      # Give the VM enough resources for a GUI
238      virtualisation = {
239        memorySize = 4096;
240        cores = 2;
241        qemu.options = [
242          "-vga virtio"
243        ];
244      };
245    };
246
247  testScript = ''
248machine.wait_for_x()
249machine.wait_for_unit("graphical.target")
250
251# Let the desktop and Orca settle
252machine.sleep(5)
253
254# Launch the a11y example, capturing logs to a file
255machine.succeed(
256    "su - user -c 'DISPLAY=:0 WAYLAND_DISPLAY= RUST_LOG=gpui=info gpui-a11y-example > /tmp/gpui.log 2>&1 &'"
257)
258
259# Wait for the window to appear
260machine.wait_until_succeeds("su - user -c 'DISPLAY=:0 xdotool search --name \"GPUI Accessibility Demo\"'", timeout=15)
261
262# Wait for accessibility activation
263machine.wait_until_succeeds("grep -q 'Accessibility activated' /tmp/gpui.log", timeout=15)
264machine.log("Accessibility activation confirmed in logs")
265
266# Give AccessKit time to register on AT-SPI
267machine.sleep(3)
268
269# Run the AT-SPI test script
270machine.succeed(
271    "su - user -c 'DISPLAY=:0 GI_TYPELIB_PATH=${giTypelibPath} ${testPython}/bin/python3 ${atspiTestScript}/bin/a11y-atspi-test'"
272)
273machine.log("AT-SPI tests passed (first run)")
274
275# Kill the app, restart Orca, and re-run
276machine.execute("pkill -f gpui-a11y-example")
277machine.sleep(1)
278machine.succeed("su - user -c 'XDG_RUNTIME_DIR=/run/user/1000 systemctl --user restart orca'")
279machine.sleep(3)
280
281# Relaunch the app
282machine.succeed(
283    "su - user -c 'DISPLAY=:0 WAYLAND_DISPLAY= RUST_LOG=gpui=info gpui-a11y-example > /tmp/gpui2.log 2>&1 &'"
284)
285machine.wait_until_succeeds("su - user -c 'DISPLAY=:0 xdotool search --name \"GPUI Accessibility Demo\"'", timeout=15)
286machine.wait_until_succeeds("grep -q 'Accessibility activated' /tmp/gpui2.log", timeout=15)
287machine.log("Accessibility activation confirmed after Orca restart")
288machine.sleep(3)
289
290# Run the AT-SPI test script again
291machine.succeed(
292    "su - user -c 'DISPLAY=:0 GI_TYPELIB_PATH=${giTypelibPath} ${testPython}/bin/python3 ${atspiTestScript}/bin/a11y-atspi-test'"
293)
294machine.log("AT-SPI tests passed (second run, after Orca restart)")
295  '';
296}
297
Served at tenant.openagents/omega Member data and write actions are omitted.