vm gitea runner

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-10-29 21:28:40 +03:00
1 parent 6908d4a695
commit 620ae1577d
6 files changed
+79 -16

No files matched your search

+2 -1
View File
@@ -38,7 +38,8 @@
'Exec=vintagestory' \
"Exec=$out/bin/PlayVintageStory"
'';
}); in
});
in
{
programs = {
firefox = {
@@ -37,8 +37,8 @@ brew update
brew install gcc cmake ninja rustup-init vulkan-headers vulkan-loader vulkan-tools molten-vk node git git-lfs
rustup-init -y --default-toolchain stable --no-modify-path
export PATH="$HOME/.cargo/bin:$(brew --prefix)/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
"$HOME/.cargo/bin/rustup" toolchain install stable
"$HOME/.cargo/bin/rustup" default stable
"$HOME/.cargo/bin/rustup" toolchain install nightly
"$HOME/.cargo/bin/rustup" default nightly
GXX="$(brew --prefix gcc)/bin/g++-16"
if [[ ! -x "$GXX" ]]; then
@@ -11,13 +11,29 @@ function Invoke-Installer([string]$File, [string]$Arguments, [int[]]$SuccessCode
}
function Download([string]$Url, [string]$Path) {
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $Path
# Always log the exact request: a thrown Invoke-WebRequest otherwise hides
# which vendor URL returned the HTTP error in the OEM transcript.
Write-Host "Downloading [$Url] to [$Path]"
try {
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $Path -TimeoutSec 600 -MaximumRedirection 10
if (-not (Test-Path $Path) -or (Get-Item -LiteralPath $Path).Length -le 0) {
throw 'The server returned no file data.'
}
} catch {
$status = 'unknown'
if ($_.Exception.Response) {
try { $status = [string]$_.Exception.Response.StatusCode } catch { }
}
Remove-Item -LiteralPath $Path -Force -ErrorAction SilentlyContinue
throw "Download failed from [$Url] (HTTP $status): $($_.Exception.Message)"
}
}
try {
New-Item -ItemType Directory -Force -Path 'C:\ci-tools', 'C:\ci-tools\downloads', 'C:\ci-tools\cargo', 'C:\ci-tools\rustup', 'C:\ci\gitea-runner' | Out-Null
# Node is needed by JavaScript-based Gitea Actions. Pin to the current Node 24 LTS line.
Write-Host 'Resolving the latest Node.js 24 LTS release from https://nodejs.org/dist/index.json.'
$nodeRelease = Invoke-RestMethod -Uri 'https://nodejs.org/dist/index.json' |
Where-Object { $_.version -match '^v24\.' -and $_.lts } |
Select-Object -First 1
@@ -26,9 +42,18 @@ try {
Download "https://nodejs.org/dist/$($nodeRelease.version)/node-$($nodeRelease.version)-x64.msi" $nodeMsi
Invoke-Installer "$env:SystemRoot\System32\msiexec.exe" "/i `"$nodeMsi`" /qn /norestart" @(0, 3010)
# Git's official installer; jobs execute as SYSTEM in this isolated guest.
$gitInstaller = 'C:\ci-tools\downloads\Git-64-bit.exe'
Download 'https://github.com/git-for-windows/git/releases/latest/download/Git-64-bit.exe' $gitInstaller
# The release asset's filename includes its version; GitHub does not
# provide a generic Git-64-bit.exe alias. Resolve the asset from the API.
Write-Host 'Resolving the latest Git for Windows x64 installer from GitHub Releases.'
$gitRelease = Invoke-RestMethod -UseBasicParsing `
-Uri 'https://api.github.com/repos/git-for-windows/git/releases/latest' `
-Headers @{ 'User-Agent' = 'gitea-vm-runner-provisioner'; 'Accept' = 'application/vnd.github+json' }
$gitAsset = $gitRelease.assets |
Where-Object { $_.name -match '^Git-[0-9.]+-64-bit\.exe$' } |
Select-Object -First 1
if (-not $gitAsset) { throw 'GitHub latest release did not contain a versioned x64 Git installer.' }
$gitInstaller = "C:\ci-tools\downloads\$($gitAsset.name)"
Download $gitAsset.browser_download_url $gitInstaller
Invoke-Installer $gitInstaller '/VERYSILENT /NORESTART /SP- /DIR="C:\Program Files\Git"' @(0, 3010)
# MSVC compatibility lane plus the MSYS2 UCRT64 GCC lane for C++26 reflection/contracts.
@@ -61,7 +86,7 @@ try {
$env:RUSTUP_HOME = 'C:\ci-tools\rustup'
$rustup = 'C:\ci-tools\downloads\rustup-init.exe'
Download 'https://win.rustup.rs/x86_64' $rustup
Invoke-Installer $rustup '-y --default-toolchain stable --no-modify-path' @(0)
Invoke-Installer $rustup '-y --default-toolchain nightly --no-modify-path' @(0)
# Ensure the native toolchain paths are available to jobs launched by Task Scheduler.
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+40 -7
View File
@@ -8,10 +8,25 @@ let
hasApiSecret = builtins.pathExists apiSecret;
in
{
flake.modules.nixos.gitea-vm-runners = { config, lib, pkgs, ... }:
flake.modules.nixos.gitea-vm-runners =
{
config,
lib,
pkgs,
...
}:
let
assets = ./_gitea-vm-runner-assets;
# The Docker Hub v3.12/latest image predates the Reims vGPU QEMU fix.
# Build a pinned upstream source revision lazily on first macOS VM start.
# Bump this revision to select a new source tree and image tag together.
macosRev = "16a5b470cdd601bae8b05b02d748d7edfb36c12e";
macosSource = builtins.fetchGit {
url = "https://github.com/dockur/macos.git";
rev = macosRev;
};
macosImage = "local/dockur-macos:${builtins.substring 0 7 macosRev}";
windowsOem = pkgs.runCommand "gitea-vm-windows-oem" { } ''
mkdir -p "$out"
cp ${assets}/windows/install.bat "$out/install.bat"
@@ -33,44 +48,55 @@ in
set -euo pipefail
state=/var/lib/gitea-vm-runners/windows
oem=/run/gitea-vm-runners/windows-oem
share=/run/gitea-vm-runners/windows-share
${pkgs.coreutils}/bin/mkdir -p "$state" /run/gitea-vm-runners
${pkgs.coreutils}/bin/rm -rf "$oem"
${pkgs.coreutils}/bin/rm -rf "$oem" "$share"
${pkgs.coreutils}/bin/mkdir -m 0700 -p "$oem"
${pkgs.coreutils}/bin/mkdir -m 0755 -p "$share"
${pkgs.coreutils}/bin/cp -R ${windowsOem}/. "$oem/"
${pkgs.coreutils}/bin/cp ${windowsOem}/install.ps1 ${windowsOem}/cxx26-feature-probe.cpp "$share/"
${registrationCopy}
${pkgs.docker}/bin/docker rm -f gitea-vm-windows >/dev/null 2>&1 || true
exec ${pkgs.docker}/bin/docker run --rm --init \
--name gitea-vm-windows \
--device=/dev/kvm --device=/dev/net/tun --cap-add=NET_ADMIN \
-e VERSION=11 -e RAM_SIZE=16G -e CPU_CORES=8 -e DISK_SIZE=160G \
-e SAMBA_READONLY=Y \
-p 127.0.0.1:18006:8006 \
-p 127.0.0.1:13389:3389/tcp \
-v /var/lib/gitea-vm-runners/windows:/storage \
-v "$oem:/oem:ro" \
-v "$share:/shared" \
dockurr/windows:latest
'';
windowsStop = pkgs.writeShellScript "gitea-vm-windows-stop" ''
set +e
${pkgs.docker}/bin/docker stop --time 120 gitea-vm-windows >/dev/null 2>&1
${pkgs.coreutils}/bin/rm -rf /run/gitea-vm-runners/windows-oem
${pkgs.coreutils}/bin/rm -rf /run/gitea-vm-runners/windows-oem /run/gitea-vm-runners/windows-share
exit 0
'';
macosStart = pkgs.writeShellScript "gitea-vm-macos-start" ''
set -euo pipefail
# Build once into Docker's persistent image store. Guest RAM is not
# allocated during idle; this image build happens only on the first start.
if ! ${pkgs.docker}/bin/docker image inspect ${macosImage} >/dev/null 2>&1; then
echo "Building pinned dockur/macos source ${macosRev} (one-time first start)..." >&2
${pkgs.docker}/bin/docker build --pull --tag ${macosImage} ${macosSource}
fi
${pkgs.coreutils}/bin/mkdir -p /var/lib/gitea-vm-runners/macos
${pkgs.docker}/bin/docker rm -f gitea-vm-macos >/dev/null 2>&1 || true
exec ${pkgs.docker}/bin/docker run --rm --init \
--name gitea-vm-macos \
--device=/dev/kvm --device=/dev/net/tun --device=/dev/dri --cap-add=NET_ADMIN \
-e VERSION=15 -e RAM_SIZE=16G -e CPU_CORES=8 -e DISK_SIZE=128G -e GPU=Y \
-e VERSION=15 -e RAM_SIZE=8G -e CPU_CORES=8 -e DISK_SIZE=128G -e GPU=Y \
-p 127.0.0.1:18007:8006 \
-p 127.0.0.1:15900:5900/tcp \
-p 127.0.0.1:15900:5900/udp \
-v /var/lib/gitea-vm-runners/macos:/storage \
-v ${macosShare}:/shared:ro \
dockurr/macos:latest
${macosImage}
'';
macosStop = pkgs.writeShellScript "gitea-vm-macos-stop" ''
@@ -81,7 +107,10 @@ in
in
{
# AMD KVM support. The host's existing docker aspect provides docker.service.
boot.kernelModules = lib.mkAfter [ "kvm-amd" "tun" ];
boot.kernelModules = lib.mkAfter [
"kvm-amd"
"tun"
];
age.secrets = lib.optionalAttrs hasApiSecret {
gitea-vm-runner-api-token = {
@@ -135,7 +164,11 @@ in
description = "Wake Gitea Windows/macOS runners for queued workflow jobs";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" "docker.service" "agenix.service" ];
after = [
"network-online.target"
"docker.service"
"agenix.service"
];
requires = [ "docker.service" ];
serviceConfig = {
Type = "simple";
+4 -1
View File
@@ -23,7 +23,10 @@
cpu.amd.updateMicrocode = lib.mkDefault true;
};
boot.kernelModules = [ "kvm-amd" "tun" ];
boot.kernelModules = [
"kvm-amd"
"tun"
];
# LACT: GPU monitoring, fan curves and overclocking.
services.lact.enable = true;
+1
View File
@@ -29,6 +29,7 @@ in
proxy-suite
docker
gitea-runner
gitea-vm-runners
nix-ld
];