gitea: add VM-based actions runner class #1082

Merged
JakeHillion merged 1 commits from jj/nyqzyzvxxsoz into main 2026-05-06 17:11:58 +01:00
Owner

Adds custom.services.gitea.actions-vm, running ephemeral act_runner
inside QEMU/KVM VMs alongside the existing nspawn Docker runner.

The Ubuntu 26.04 cloud qcow2 is fetched and customised inside
vmTools.runInLinuxVM. The image gets the act_runner closure plus
nodejs_24 copied into /nix/store, with each package's bin/* bulk-
symlinked into /usr/local/bin. A runner user (UID/GID 1001, HOME
/home/runner, locked password) is baked in to match GitHub-hosted
runner conventions, with passwordless sudo via /etc/sudoers.d/runner.
cloud-init is restricted to the NoCloud datasource so it applies
network-config quickly without scanning EC2/Azure endpoints, and
cloud-initramfs-growroot remains in place so partition + ext4 auto-
grow at boot.

At runtime each instance creates a fresh 40 GiB-virtual qcow2 overlay
backed by the read-only Nix-store image, registers an ephemeral
runner with Gitea, stages cloud-init meta-data + network-config
(static per-instance IP matched by MAC) alongside the resulting
.runner JSON and config.yaml, packages the lot into an ISO9660 disk
labelled cidata via xorriso, and launches qemu-system-x86_64 with
both disks plus a virtio-balloon device with free-page-reporting
enabled. cloud-init applies the network config; the in-VM
gitea-runner.service then runs as the runner user, mounts cidata
via ExecStartPre=+ and copies credentials into /var/lib/gitea-runner
before exec'ing act_runner directly.

A dedicated br-runners bridge handles networking with NAT to eth0 and
iptables FORWARD drops for RFC1918 and CGNAT ranges. Per-VM IPs are
assigned statically as 10.108.28.(10+i). qemu-bridge-helper is
capability-wrapped (cap_net_admin+ep) so the qemu process can attach
its TAP without holding cap_net_admin itself; the host service runs
as a fixed UID with NoNewPrivileges=false so the kernel honours the
file caps on exec (DynamicUser is incompatible — it implies and
enforces NoNewPrivileges, which would block the cap inheritance).

Disposable overlays use systemd CacheDirectory= under
/var/cache/gitea-actions-vm, persisted via a new
custom.impermanence.cache.extraDirs option so they land on the
SSD-backed /cache subvol (wiped on boot) rather than the tmpfs root.

Enables one instance on boron at 12 GiB / 6 vCPU.

Test plan:

Adds custom.services.gitea.actions-vm, running ephemeral act_runner inside QEMU/KVM VMs alongside the existing nspawn Docker runner. The Ubuntu 26.04 cloud qcow2 is fetched and customised inside vmTools.runInLinuxVM. The image gets the act_runner closure plus nodejs_24 copied into /nix/store, with each package's bin/* bulk- symlinked into /usr/local/bin. A `runner` user (UID/GID 1001, HOME /home/runner, locked password) is baked in to match GitHub-hosted runner conventions, with passwordless sudo via /etc/sudoers.d/runner. cloud-init is restricted to the NoCloud datasource so it applies network-config quickly without scanning EC2/Azure endpoints, and cloud-initramfs-growroot remains in place so partition + ext4 auto- grow at boot. At runtime each instance creates a fresh 40 GiB-virtual qcow2 overlay backed by the read-only Nix-store image, registers an ephemeral runner with Gitea, stages cloud-init meta-data + network-config (static per-instance IP matched by MAC) alongside the resulting .runner JSON and config.yaml, packages the lot into an ISO9660 disk labelled cidata via xorriso, and launches qemu-system-x86_64 with both disks plus a virtio-balloon device with free-page-reporting enabled. cloud-init applies the network config; the in-VM gitea-runner.service then runs as the `runner` user, mounts cidata via ExecStartPre=+ and copies credentials into /var/lib/gitea-runner before exec'ing act_runner directly. A dedicated br-runners bridge handles networking with NAT to eth0 and iptables FORWARD drops for RFC1918 and CGNAT ranges. Per-VM IPs are assigned statically as 10.108.28.(10+i). qemu-bridge-helper is capability-wrapped (cap_net_admin+ep) so the qemu process can attach its TAP without holding cap_net_admin itself; the host service runs as a fixed UID with NoNewPrivileges=false so the kernel honours the file caps on exec (DynamicUser is incompatible — it implies and enforces NoNewPrivileges, which would block the cap inheritance). Disposable overlays use systemd CacheDirectory= under /var/cache/gitea-actions-vm, persisted via a new custom.impermanence.cache.extraDirs option so they land on the SSD-backed /cache subvol (wiped on boot) rather than the tmpfs root. Enables one instance on boron at 12 GiB / 6 vCPU. Test plan: - CI - Migrated personal-agent with https://gitea.hillion.co.uk/JakeHillion/personal-agent/pulls/53 - all looks good.
JakeHillion force-pushed jj/nyqzyzvxxsoz from 9bf1361b9f to 09a98285f7 2026-05-05 20:49:49 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 09a98285f7 to 265daffcfd 2026-05-05 21:46:08 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 265daffcfd to b7e673c354 2026-05-05 21:48:16 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from b7e673c354 to 2c8be9e1e7 2026-05-05 22:02:05 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 2c8be9e1e7 to c9f045fc30 2026-05-05 22:12:11 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from c9f045fc30 to 2c2a14a9a8 2026-05-05 22:30:05 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 2c2a14a9a8 to 432c826256 2026-05-05 22:31:22 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 432c826256 to 316185f7ba 2026-05-05 22:41:41 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 316185f7ba to 0106a664cf 2026-05-05 22:49:49 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 0106a664cf to bb74a0c2cd 2026-05-05 22:54:45 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from bb74a0c2cd to 8bb929357d 2026-05-05 23:01:41 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 8bb929357d to d53ad2612b 2026-05-05 23:18:00 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from d53ad2612b to 15c49ce2b6 2026-05-06 00:01:30 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 15c49ce2b6 to b2073f3de2 2026-05-06 11:26:09 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from b2073f3de2 to 01e4644aee 2026-05-06 11:59:58 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 01e4644aee to e247490d2e 2026-05-06 12:08:23 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from e247490d2e to 2c2a3b83ec 2026-05-06 12:16:24 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 2c2a3b83ec to 59ef0592a1 2026-05-06 12:26:26 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 59ef0592a1 to eda1f4c9ae 2026-05-06 13:36:49 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from eda1f4c9ae to 1eba8dc465 2026-05-06 13:59:14 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 1eba8dc465 to a2ac84c87b 2026-05-06 14:19:20 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from a2ac84c87b to 308ed65260 2026-05-06 15:07:50 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 308ed65260 to 2978aa954b 2026-05-06 16:50:51 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 2978aa954b to 1fe6133442 2026-05-06 16:56:25 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 1fe6133442 to 4b2719b8c6 2026-05-06 17:06:10 +01:00 Compare
JakeHillion force-pushed jj/nyqzyzvxxsoz from 4b2719b8c6 to 71b61e9462 2026-05-06 17:06:58 +01:00 Compare
JakeHillion added 1 commit 2026-05-06 17:07:41 +01:00
gitea: add VM-based actions runner class
commit-validation / validate-single-commit (pull_request) Successful in 5s
buildbot/nix-eval Build done. (1004 warnings)
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
24b7ece4ab
Adds custom.services.gitea.actions-vm, running ephemeral act_runner
inside QEMU/KVM VMs alongside the existing nspawn Docker runner.

The Ubuntu 26.04 cloud qcow2 is fetched and customised inside
vmTools.runInLinuxVM. The image gets the act_runner closure plus
nodejs_24 copied into /nix/store, with each package's bin/* bulk-
symlinked into /usr/local/bin. A `runner` user (UID/GID 1001, HOME
/home/runner, locked password) is baked in to match GitHub-hosted
runner conventions, with passwordless sudo via /etc/sudoers.d/runner.
cloud-init is restricted to the NoCloud datasource so it applies
network-config quickly without scanning EC2/Azure endpoints, and
cloud-initramfs-growroot remains in place so partition + ext4 auto-
grow at boot.

At runtime each instance creates a fresh 40 GiB-virtual qcow2 overlay
backed by the read-only Nix-store image, registers an ephemeral
runner with Gitea, stages cloud-init meta-data + network-config
(static per-instance IP matched by MAC) alongside the resulting
.runner JSON and config.yaml, packages the lot into an ISO9660 disk
labelled cidata via xorriso, and launches qemu-system-x86_64 with
both disks plus a virtio-balloon device with free-page-reporting
enabled. cloud-init applies the network config; the in-VM
gitea-runner.service then runs as the `runner` user, mounts cidata
via ExecStartPre=+ and copies credentials into /var/lib/gitea-runner
before exec'ing act_runner directly.

A dedicated br-runners bridge handles networking with NAT to eth0 and
iptables FORWARD drops for RFC1918 and CGNAT ranges. Per-VM IPs are
assigned statically as 10.108.28.(10+i). qemu-bridge-helper is
capability-wrapped (cap_net_admin+ep) so the qemu process can attach
its TAP without holding cap_net_admin itself; the host service runs
as a fixed UID with NoNewPrivileges=false so the kernel honours the
file caps on exec (DynamicUser is incompatible — it implies and
enforces NoNewPrivileges, which would block the cap inheritance).

Disposable overlays use systemd CacheDirectory= under
/var/cache/gitea-actions-vm, persisted via a new
custom.impermanence.cache.extraDirs option so they land on the
SSD-backed /cache subvol (wiped on boot) rather than the tmpfs root.

Enables one instance on boron at 12 GiB / 6 vCPU.

Test plan:
- CI
- Migrated personal-agent with
  JakeHillion/personal-agent#53 - all
  looks good.
JakeHillion force-pushed jj/nyqzyzvxxsoz from 71b61e9462 to 24b7ece4ab 2026-05-06 17:07:41 +01:00 Compare
JakeHillion scheduled this pull request to auto merge when all checks succeed 2026-05-06 17:07:55 +01:00
JakeHillion merged commit 24b7ece4ab into main 2026-05-06 17:11:58 +01:00
JakeHillion deleted branch jj/nyqzyzvxxsoz 2026-05-06 17:11:58 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JakeHillion/nixos#1082