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
10 files changed
+102 -39

No files matched your search

+3 -3
View File
@@ -81,9 +81,9 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
vintagestory-nix = { vintagestory-nix = {
url = "git+https://codeberg.org/PierreBorine/vintagestory-nix"; url = "git+https://codeberg.org/PierreBorine/vintagestory-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# The owner's Neovim configuration (modules/cli/neovim.nix): plain files, # The owner's Neovim configuration (modules/cli/neovim.nix): plain files,
# not a flake. The repository is private and Nix has no credentials for # not a flake. The repository is private and Nix has no credentials for
# HTTPS, so it is fetched over SSH with the key of the user who runs nix # HTTPS, so it is fetched over SSH with the key of the user who runs nix
+9 -9
View File
@@ -32,16 +32,16 @@ in
}; };
jujutsu = { jujutsu = {
enable = true; enable = true;
settings = { settings = {
user = { user = {
name = owner.fullName; name = owner.fullName;
inherit (owner) email; inherit (owner) email;
};
ui = {
diff.format = "color-words";
};
}; };
ui = {
diff.format = "color-words";
};
};
}; };
# Syntax-highlighted diffs as the git pager. # Syntax-highlighted diffs as the git pager.
+3 -2
View File
@@ -7,7 +7,7 @@
flake.modules.homeManager.apps = flake.modules.homeManager.apps =
{ pkgs, ... }: { pkgs, ... }:
let let
vintagestory = pkgs.vintagestoryPackages.v1-22-7.overrideAttrs (old: { vintagestory = pkgs.vintagestoryPackages.v1-22-7.overrideAttrs (old: {
# Put the actual executable in the game directory. # Put the actual executable in the game directory.
postInstall = (old.postInstall or "") + '' postInstall = (old.postInstall or "") + ''
install -Dm755 ${./PlayVintageStory} \ install -Dm755 ${./PlayVintageStory} \
@@ -38,7 +38,8 @@
'Exec=vintagestory' \ 'Exec=vintagestory' \
"Exec=$out/bin/PlayVintageStory" "Exec=$out/bin/PlayVintageStory"
''; '';
}); in });
in
{ {
programs = { programs = {
firefox = { 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 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 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" 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" toolchain install nightly
"$HOME/.cargo/bin/rustup" default stable "$HOME/.cargo/bin/rustup" default nightly
GXX="$(brew --prefix gcc)/bin/g++-16" GXX="$(brew --prefix gcc)/bin/g++-16"
if [[ ! -x "$GXX" ]]; then if [[ ! -x "$GXX" ]]; then
@@ -11,13 +11,29 @@ function Invoke-Installer([string]$File, [string]$Arguments, [int[]]$SuccessCode
} }
function Download([string]$Url, [string]$Path) { 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 { 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 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. # 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' | $nodeRelease = Invoke-RestMethod -Uri 'https://nodejs.org/dist/index.json' |
Where-Object { $_.version -match '^v24\.' -and $_.lts } | Where-Object { $_.version -match '^v24\.' -and $_.lts } |
Select-Object -First 1 Select-Object -First 1
@@ -26,9 +42,18 @@ try {
Download "https://nodejs.org/dist/$($nodeRelease.version)/node-$($nodeRelease.version)-x64.msi" $nodeMsi 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) 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. # The release asset's filename includes its version; GitHub does not
$gitInstaller = 'C:\ci-tools\downloads\Git-64-bit.exe' # provide a generic Git-64-bit.exe alias. Resolve the asset from the API.
Download 'https://github.com/git-for-windows/git/releases/latest/download/Git-64-bit.exe' $gitInstaller 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) 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. # 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' $env:RUSTUP_HOME = 'C:\ci-tools\rustup'
$rustup = 'C:\ci-tools\downloads\rustup-init.exe' $rustup = 'C:\ci-tools\downloads\rustup-init.exe'
Download 'https://win.rustup.rs/x86_64' $rustup 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. # Ensure the native toolchain paths are available to jobs launched by Task Scheduler.
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine') $machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+1 -1
View File
@@ -13,7 +13,7 @@ in
enable = true; enable = true;
setSocketVariable = true; setSocketVariable = true;
daemon.settings = { daemon.settings = {
experimental = true; experimental = true;
}; };
}; };
+8 -8
View File
@@ -37,14 +37,14 @@ in
]; ];
hostPackages = with pkgs; [ hostPackages = with pkgs; [
bashInteractive bashInteractive
coreutils coreutils
curl curl
gitMinimal gitMinimal
nix nix
nodejs_26 nodejs_26
wget wget
]; ];
settings = { settings = {
runner = { runner = {
capacity = 5; capacity = 5;
+41 -8
View File
@@ -8,10 +8,25 @@ let
hasApiSecret = builtins.pathExists apiSecret; hasApiSecret = builtins.pathExists apiSecret;
in in
{ {
flake.modules.nixos.gitea-vm-runners = { config, lib, pkgs, ... }: flake.modules.nixos.gitea-vm-runners =
{
config,
lib,
pkgs,
...
}:
let let
assets = ./_gitea-vm-runner-assets; 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" { } '' windowsOem = pkgs.runCommand "gitea-vm-windows-oem" { } ''
mkdir -p "$out" mkdir -p "$out"
cp ${assets}/windows/install.bat "$out/install.bat" cp ${assets}/windows/install.bat "$out/install.bat"
@@ -33,44 +48,55 @@ in
set -euo pipefail set -euo pipefail
state=/var/lib/gitea-vm-runners/windows state=/var/lib/gitea-vm-runners/windows
oem=/run/gitea-vm-runners/windows-oem 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/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 0700 -p "$oem"
${pkgs.coreutils}/bin/mkdir -m 0755 -p "$share"
${pkgs.coreutils}/bin/cp -R ${windowsOem}/. "$oem/" ${pkgs.coreutils}/bin/cp -R ${windowsOem}/. "$oem/"
${pkgs.coreutils}/bin/cp ${windowsOem}/install.ps1 ${windowsOem}/cxx26-feature-probe.cpp "$share/"
${registrationCopy} ${registrationCopy}
${pkgs.docker}/bin/docker rm -f gitea-vm-windows >/dev/null 2>&1 || true ${pkgs.docker}/bin/docker rm -f gitea-vm-windows >/dev/null 2>&1 || true
exec ${pkgs.docker}/bin/docker run --rm --init \ exec ${pkgs.docker}/bin/docker run --rm --init \
--name gitea-vm-windows \ --name gitea-vm-windows \
--device=/dev/kvm --device=/dev/net/tun --cap-add=NET_ADMIN \ --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 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:18006:8006 \
-p 127.0.0.1:13389:3389/tcp \ -p 127.0.0.1:13389:3389/tcp \
-v /var/lib/gitea-vm-runners/windows:/storage \ -v /var/lib/gitea-vm-runners/windows:/storage \
-v "$oem:/oem:ro" \ -v "$oem:/oem:ro" \
-v "$share:/shared" \
dockurr/windows:latest dockurr/windows:latest
''; '';
windowsStop = pkgs.writeShellScript "gitea-vm-windows-stop" '' windowsStop = pkgs.writeShellScript "gitea-vm-windows-stop" ''
set +e set +e
${pkgs.docker}/bin/docker stop --time 120 gitea-vm-windows >/dev/null 2>&1 ${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 exit 0
''; '';
macosStart = pkgs.writeShellScript "gitea-vm-macos-start" '' macosStart = pkgs.writeShellScript "gitea-vm-macos-start" ''
set -euo pipefail 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.coreutils}/bin/mkdir -p /var/lib/gitea-vm-runners/macos
${pkgs.docker}/bin/docker rm -f gitea-vm-macos >/dev/null 2>&1 || true ${pkgs.docker}/bin/docker rm -f gitea-vm-macos >/dev/null 2>&1 || true
exec ${pkgs.docker}/bin/docker run --rm --init \ exec ${pkgs.docker}/bin/docker run --rm --init \
--name gitea-vm-macos \ --name gitea-vm-macos \
--device=/dev/kvm --device=/dev/net/tun --device=/dev/dri --cap-add=NET_ADMIN \ --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:18007:8006 \
-p 127.0.0.1:15900:5900/tcp \ -p 127.0.0.1:15900:5900/tcp \
-p 127.0.0.1:15900:5900/udp \ -p 127.0.0.1:15900:5900/udp \
-v /var/lib/gitea-vm-runners/macos:/storage \ -v /var/lib/gitea-vm-runners/macos:/storage \
-v ${macosShare}:/shared:ro \ -v ${macosShare}:/shared:ro \
dockurr/macos:latest ${macosImage}
''; '';
macosStop = pkgs.writeShellScript "gitea-vm-macos-stop" '' macosStop = pkgs.writeShellScript "gitea-vm-macos-stop" ''
@@ -81,7 +107,10 @@ in
in in
{ {
# AMD KVM support. The host's existing docker aspect provides docker.service. # 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 { age.secrets = lib.optionalAttrs hasApiSecret {
gitea-vm-runner-api-token = { gitea-vm-runner-api-token = {
@@ -135,7 +164,11 @@ in
description = "Wake Gitea Windows/macOS runners for queued workflow jobs"; description = "Wake Gitea Windows/macOS runners for queued workflow jobs";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
after = [ "network-online.target" "docker.service" "agenix.service" ]; after = [
"network-online.target"
"docker.service"
"agenix.service"
];
requires = [ "docker.service" ]; requires = [ "docker.service" ];
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
@@ -148,4 +181,4 @@ in
}; };
}; };
} }
+4 -1
View File
@@ -23,7 +23,10 @@
cpu.amd.updateMicrocode = lib.mkDefault true; cpu.amd.updateMicrocode = lib.mkDefault true;
}; };
boot.kernelModules = [ "kvm-amd" "tun" ]; boot.kernelModules = [
"kvm-amd"
"tun"
];
# LACT: GPU monitoring, fan curves and overclocking. # LACT: GPU monitoring, fan curves and overclocking.
services.lact.enable = true; services.lact.enable = true;
+1
View File
@@ -29,6 +29,7 @@ in
proxy-suite proxy-suite
docker docker
gitea-runner gitea-runner
gitea-vm-runners
nix-ld nix-ld
]; ];