# On-demand Gitea Windows/macOS runners ## Behavior and resource use `gitea-vm-runner-dispatcher.service` polls `https://git.faumaray.com/api/v1/user/actions/jobs` every 15 seconds for `queued`, `pending`, and `in_progress` jobs. When a job's labels include `windows-x64` or `macos-x64`, it starts only that guest's systemd unit. After 90 seconds with no matching jobs, it stops the guest. If Gitea or the network cannot be queried, the controller leaves active guests running rather than risking an active job being interrupted. Both guests are **not enabled at boot**. Idle means the Docker container is stopped and its guest RAM/CPU usage is released; the persistent disk remains on disk. A running Windows guest is configured with 8 GiB RAM/4 vCPUs; macOS with 8 GiB/2 vCPUs for AMD stability. Only the requested guest starts, unless queued jobs for both labels exist. The services bind the web consoles and RDP/VNC to `127.0.0.1` only. The API endpoint is documented by Gitea at . The controller uses a separate API access token, not the runner registration token. ## 1. Create the API token secret Create a dedicated Gitea access token that can read Actions job metadata for every repository whose jobs should wake these guests. Do not reuse the runner registration token for API polling. Create a local plaintext file in the repository's expected `TOKEN=` format: ```sh umask 077 printf 'TOKEN=%s\n' 'YOUR_GITEA_READ_API_TOKEN' > /tmp/gitea-vm-runner-api-token nix run .#secret-from-file -- gitea-vm-runner-api-token.age /tmp/gitea-vm-runner-api-token rm -f /tmp/gitea-vm-runner-api-token ``` Add the encrypted output under `secrets/gitea-vm-runner-api-token.age` to Git. The expected file should be present at flake evaluation time, like the existing `gitea-runner-token.age`, so `agenix` creates `/run/agenix/gitea-vm-runner-api-token` at runtime. If the secret is absent, the module emits a warning and the dispatcher is not enabled. The Windows runner is auto-registered by the OEM bootstrap when `secrets/gitea-runner-token.age` exists, using your existing registration token. macOS asks for the runner registration token during its one-time bootstrap; the API token is never mounted into either guest. ## 2. Review and activate the Nix change The added host aspect is imported by `modules/hosts/desktop/host.nix`; it uses the existing rootful Docker configuration. It does not add `virtualisation.oci-containers`, Compose, or a boot dependency on either VM. Check hardware virtualization and KVM first: ```sh lscpu | grep -E 'Architecture|Virtualization|Model name' grep -m1 -o 'avx2' /proc/cpuinfo || true ls -l /dev/kvm ``` Then validate the flake and test the new system configuration before making it the default: ```sh nix flake check sudo nixos-rebuild test --flake .#desktop systemctl status gitea-vm-runner-dispatcher journalctl -u gitea-vm-runner-dispatcher -f ``` The dispatcher starts only if the API secret exists. The two VM units intentionally have no `wantedBy` and won't boot automatically. When the API token is configured, you can start them on demand using a matching queued workflow or a keep-awake pin (below). ## 3. Windows first boot The first matching `windows-x64` queued job wakes Windows. The upstream `/oem/install.bat` hook installs: - Windows Node.js 24 LTS and Git for Windows (for Gitea Actions prerequisites); - Visual Studio Build Tools/C++ and Windows SDK (MSVC platform compatibility lane); - MSYS2 UCRT64 GCC 16, CMake, Ninja, Vulkan headers/loader/tools (C++26 contracts/reflection lane); - Vulkan SDK and Rust stable. The script compiles and runs `ci/cxx26-feature-probe.cpp` using GCC 16 with contracts and reflection enabled. It fails closed—registration does not happen until that exact compiler invocation passes. On subsequent boots the startup scheduled task brings up the already-registered runner. If provisioning fails, check the VM using the local-only console at `http://127.0.0.1:18006` or RDP to `127.0.0.1:13389`; logs are written to `C:\OEM\gitea-runner-install.log`. The first automatic installation can be lengthy, and the matching job remains queued while the guest is provisioned. ## 4. macOS first boot and bootstrap macOS needs one interactive installation. To hold it awake for setup, run: ```sh sudo mkdir -p /var/lib/gitea-vm-runners/keep-awake sudo touch /var/lib/gitea-vm-runners/keep-awake/macos-x64 sudo systemctl start gitea-vm-macos ``` Open `http://127.0.0.1:18007`, complete the macOS installer, and create a local account. In the macOS guest Terminal, mount the read-only Nix-provided bootstrap share: ```sh sudo -S mount_9p shared ``` Use Finder's Go → Computer view to locate the mounted `shared` volume. In Terminal, change into that volume and run: ```sh bash ./bootstrap.sh ``` The bootstrap installs Homebrew non-interactively if absent (the first run still requires Xcode Command Line Tools and may ask for the local account password), then installs GCC 16, CMake/Ninja, Rust stable, Node, Git, Vulkan headers/loader/tools and MoltenVK. It validates C++26 contracts + reflection, then registers `macos-x64:host` and installs a LaunchDaemon. It prompts for the runner registration token. The runner will start automatically on future guest boots. When setup is complete, remove the pin. The dispatcher will stop the guest after its idle grace period if no macOS job is queued or running: ```sh sudo rm -f /var/lib/gitea-vm-runners/keep-awake/macos-x64 ``` The macOS guest is configured with 8 GiB maximum RAM during installation and 2 virtual CPUs, to stay conservative on AMD. Avoid raising installation RAM above 8 GiB. If performance needs it, test 4 vCPUs after confirming the guest is stable. ## 5. Runner labels and example workflow jobs Runner labels are registered as `linux` (existing runner, now with GCC 16 tools), `windows-x64`, and `macos-x64`. Use labels without the `:host` executor suffix in `runs-on`: ```yaml name: C++26 cross-platform on: [push, pull_request] jobs: linux: runs-on: linux steps: - uses: actions/checkout@v4 - run: g++ --version - run: g++ -std=c++26 -fcontracts -freflection -fcontract-evaluation-semantic=enforce ci/cxx26-feature-probe.cpp -o cxx26-probe - run: ./cxx26-probe windows: runs-on: windows-x64 steps: - uses: actions/checkout@v4 - shell: powershell run: | g++ --version g++ -std=c++26 -fcontracts -freflection -fcontract-evaluation-semantic=enforce ci/cxx26-feature-probe.cpp -o cxx26-probe.exe .\cxx26-probe.exe macos: runs-on: macos-x64 steps: - uses: actions/checkout@v4 - run: g++-16 --version - run: g++-16 -std=c++26 -fcontracts -freflection -fcontract-evaluation-semantic=enforce ci/cxx26-feature-probe.cpp -o cxx26-probe - run: ./cxx26-probe ``` The probe is an actual compile/run gate, not a check of compiler version text. GCC documents Contracts via `-fcontracts` and P2996 reflection via `-freflection` starting with GCC 16: . ## 6. Vulkan and Rust notes The Linux host is given native GCC 16, CMake/Ninja, Vulkan headers/loader/tools, and Rust/Cargo through the NixOS runner's `hostPackages`. On Windows the MSVC + Vulkan SDK lane covers Windows SDK/linking behavior; the GCC 16 lane validates the required C++26 features. On macOS, `GPU=Y` exposes the host AMD DRM device to dockur's Reims vGPU, and MoltenVK maps Vulkan onto Metal. This can support basic virtual-GPU testing, but a VM's virtual GPU is not equivalent to testing on a physical Mac/GPU. Keep OS-level platform tests separate from the C++26 compiler feature gate. Gitea Runner's `host` executor runs workflows as the runner's user without job isolation. These native Windows/macOS runners should only execute trusted repositories and workflows. Do not expose the local console/RDP/VNC ports to the LAN or internet. Docker image tags are currently `latest`; pin image digests if exact VM image reproducibility is required. ## 7. Manual controls and logs ```sh # Manually keep a guest awake while preparing it. Remove the marker afterward. sudo touch /var/lib/gitea-vm-runners/keep-awake/windows-x64 sudo systemctl start gitea-vm-windows sudo rm -f /var/lib/gitea-vm-runners/keep-awake/windows-x64 # View controller/guest logs and state. journalctl -u gitea-vm-runner-dispatcher -f journalctl -u gitea-vm-windows -f journalctl -u gitea-vm-macos -f systemctl is-active gitea-vm-windows gitea-vm-macos docker ps --filter name=gitea-vm- ``` Persistent guest disks are under `/var/lib/gitea-vm-runners/windows` and `/var/lib/gitea-vm-runners/macos`. Stopping the guest frees configured guest RAM; it does not delete these disks. Back them up before removing either storage directory. ## Compatibility/legal note GCC 16 implements the C++26 Contracts feature and P2996 reflection; these are still evolving draft-standard features, so the compile/run probe intentionally decides support based on behavior. Upstream `dockur/macos` documents Linux/KVM + AVX2 as technical requirements, but also states that Apple's macOS EULA permits running macOS only on Apple-branded hardware. This AMD host is therefore not a compliant place to run a macOS guest under that stated EULA. For compliant macOS CI, use an Apple Mac runner. The macOS aspect here is included as a technical configuration, not a statement that its use on non-Apple hardware is permitted.