|
128 | 128 |
|
129 | 129 | dontInstall = true; |
130 | 130 | }; |
| 131 | + |
| 132 | + # QEMU integration test (requires KVM) |
| 133 | + qemu-integration = pkgs.stdenv.mkDerivation { |
| 134 | + pname = "xenomorph-qemu-integration"; |
| 135 | + inherit version; |
| 136 | + src = ./.; |
| 137 | + |
| 138 | + nativeBuildInputs = [ |
| 139 | + pkgs.zig |
| 140 | + pkgs.qemu_kvm |
| 141 | + pkgs.cpio |
| 142 | + pkgs.gzip |
| 143 | + ]; |
| 144 | + |
| 145 | + dontConfigure = true; |
| 146 | + dontInstall = true; |
| 147 | + |
| 148 | + # Require KVM for this test |
| 149 | + requiredSystemFeatures = [ "kvm" ]; |
| 150 | + |
| 151 | + buildPhase = '' |
| 152 | + export ZIG_GLOBAL_CACHE_DIR=$(mktemp -d) |
| 153 | +
|
| 154 | + # Set up environment for the test |
| 155 | + export KERNEL_PATH="${pkgs.linuxPackages_latest.kernel}/bzImage" |
| 156 | + export BUSYBOX_PATH="${pkgs.pkgsStatic.busybox}/bin/busybox" |
| 157 | + export QEMU_PATH="${pkgs.qemu_kvm}/bin/qemu-system-x86_64" |
| 158 | + export XENOMORPH_PATH="${xenomorphStatic}/bin/xenomorph" |
| 159 | +
|
| 160 | + # Build and run the QEMU test |
| 161 | + zig build test-qemu -Doptimize=ReleaseSafe |
| 162 | + ./zig-out/bin/qemu-test |
| 163 | +
|
| 164 | + touch $out |
| 165 | + ''; |
| 166 | + }; |
131 | 167 | }; |
132 | 168 |
|
133 | 169 | # QEMU integration test |
|
143 | 179 |
|
144 | 180 | export KERNEL_PATH BUSYBOX_PATH XENOMORPH_PATH QEMU_PATH |
145 | 181 |
|
| 182 | + # Set up Zig cache directory |
| 183 | + export ZIG_GLOBAL_CACHE_DIR="''${XDG_CACHE_HOME:-$HOME/.cache}/zig" |
| 184 | +
|
146 | 185 | # Build and run the QEMU test executable |
147 | 186 | ${pkgs.zig}/bin/zig build test-qemu -Doptimize=ReleaseSafe |
148 | 187 | ./zig-out/bin/qemu-test |
|
157 | 196 | busybox |
158 | 197 | cpio |
159 | 198 | gzip |
| 199 | + # Ensure proper less is available (busybox's less breaks git pager) |
| 200 | + less |
160 | 201 | ]; |
161 | 202 |
|
162 | 203 | shellHook = '' |
| 204 | + # Use real less instead of busybox's (fixes git pager) |
| 205 | + export PAGER="${pkgs.less}/bin/less" |
| 206 | +
|
163 | 207 | echo "Xenomorph development environment" |
164 | 208 | echo "Zig version: $(zig version)" |
165 | 209 | echo "" |
|
176 | 220 | builds = { |
177 | 221 | exclude = [ "aarch64-darwin" "x86_64-darwin" ]; |
178 | 222 | }; |
| 223 | + # Enable KVM for QEMU integration tests |
| 224 | + server.enable = true; |
179 | 225 | }; |
180 | 226 | }; |
181 | 227 | } |
0 commit comments