-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
123 lines (112 loc) · 3.91 KB
/
flake.nix
File metadata and controls
123 lines (112 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
description = "Nix flake for accessibility-cli development";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSystem = f:
nixpkgs.lib.genAttrs systems (system:
f {
pkgs = import nixpkgs {
inherit system;
};
});
in
{
packages = forEachSystem ({ pkgs }: {
run-linux-e2e-tests = pkgs.writeShellApplication {
name = "run-linux-e2e-tests";
runtimeInputs = with pkgs; [
cargo
rustc
dbus
gnome-calculator
wmctrl
xdotool
xauth
xorg.xorgserver
];
text = ''
export GTK_MODULES="gail:atk-bridge"
display_num=99
while [ -e "/tmp/.X''${display_num}-lock" ]; do
display_num=$((display_num + 1))
done
export DISPLAY=":''${display_num}"
Xvfb "$DISPLAY" -screen 0 1440x900x24 >/tmp/accessibility-cli-xvfb.log 2>&1 &
xvfb_pid=$!
cleanup() {
kill "$xvfb_pid" >/dev/null 2>&1 || true
wait "$xvfb_pid" >/dev/null 2>&1 || true
}
trap cleanup EXIT INT TERM
sleep 1
dbus-run-session -- cargo test -p accessibility-core --test gnome_calculator_e2e -- --nocapture "$@"
'';
};
});
devShells = forEachSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rustfmt
clippy
pkg-config
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
self.packages.${pkgs.stdenv.hostPlatform.system}.run-linux-e2e-tests
dbus
gnome-calculator
wmctrl
xdotool
xauth
xorg.xorgserver
dbus.dev
at-spi2-core.dev
libx11.dev
libxcb.dev
];
shellHook = ''
echo "Loaded accessibility-cli development shell"
echo "Rust toolchain: $(rustc --version)"
${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
cleanup_accessibility_cli_shell() {
if [ -n "''${ACCESSIBILITY_CLI_XVFB_PID:-}" ]; then
kill "''${ACCESSIBILITY_CLI_XVFB_PID}" >/dev/null 2>&1 || true
wait "''${ACCESSIBILITY_CLI_XVFB_PID}" >/dev/null 2>&1 || true
fi
if [ -n "''${ACCESSIBILITY_CLI_DBUS_PID:-}" ]; then
kill "''${ACCESSIBILITY_CLI_DBUS_PID}" >/dev/null 2>&1 || true
wait "''${ACCESSIBILITY_CLI_DBUS_PID}" >/dev/null 2>&1 || true
fi
}
trap cleanup_accessibility_cli_shell EXIT
if [ -z "''${DISPLAY:-}" ]; then
display_num=99
while [ -e "/tmp/.X''${display_num}-lock" ]; do
display_num=$((display_num + 1))
done
export DISPLAY=":''${display_num}"
Xvfb "$DISPLAY" -screen 0 1440x900x24 >/tmp/accessibility-cli-xvfb.log 2>&1 &
export ACCESSIBILITY_CLI_XVFB_PID=$!
sleep 1
echo "Started Xvfb on $DISPLAY"
fi
dbus_info="$(${pkgs.dbus}/bin/dbus-daemon --session --fork --print-address=1 --print-pid=1)"
export DBUS_SESSION_BUS_ADDRESS="$(printf '%s\n' "$dbus_info" | sed -n '1p')"
export ACCESSIBILITY_CLI_DBUS_PID="$(printf '%s\n' "$dbus_info" | sed -n '2p')"
echo "Started D-Bus session: $DBUS_SESSION_BUS_ADDRESS"
echo "Linux GUI E2E runner: run-linux-e2e-tests"
''}
'';
};
});
};
}