diff --git a/nix-runner/flake.lock b/nix-runner/flake.lock new file mode 100644 index 0000000..5fd6f52 --- /dev/null +++ b/nix-runner/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767379071, + "narHash": "sha256-EgE0pxsrW9jp9YFMkHL9JMXxcqi/OoumPJYwf+Okucw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fb7944c166a3b630f177938e478f0378e64ce108", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix-runner/flake.nix b/nix-runner/flake.nix new file mode 100644 index 0000000..3e48255 --- /dev/null +++ b/nix-runner/flake.nix @@ -0,0 +1,58 @@ +# ABOUTME: Flake to build a custom Nix Docker image for Gitea Actions. +# ABOUTME: Includes coreutils (/bin/sleep), modern Nix with flakes, and CI tools. +{ + description = "Nix runner image for Gitea Actions"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { + packages.default = pkgs.dockerTools.buildImage { + name = "gitea.v.paler.net/ppetru/nix-runner"; + tag = "v4"; + + copyToRoot = pkgs.buildEnv { + name = "image-root"; + paths = with pkgs; [ + # Core utilities (provides /bin/sleep that act_runner needs) + coreutils-full + bash + # Nix itself + nix + # For actions that need node + nodejs_20 + # Common CI tools + git + curl + jq + skopeo + # CA certificates for HTTPS + cacert + ]; + pathsToLink = [ "/bin" "/etc" ]; + }; + + # Create temp directories without runAsRoot (which needs KVM) + extraCommands = '' + mkdir -p -m 1777 tmp + mkdir -p -m 1777 var/tmp + ''; + + config = { + Env = [ + "NIX_PAGER=cat" + "USER=root" + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + "NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + "NIX_CONFIG=experimental-features = nix-command flakes\nsandbox = false\nbuild-users-group =\nsubstituters = http://c3.mule-stork.ts.net:8501 https://cache.nixos.org\ntrusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= c3:sI3l1RN80xdehzXLA8u2P6352B0SyRPs2XiYy/YWYro=" + ]; + }; + }; + }); +} diff --git a/services/act-runner.hcl b/services/act-runner.hcl new file mode 100644 index 0000000..00a5276 --- /dev/null +++ b/services/act-runner.hcl @@ -0,0 +1,75 @@ +# ABOUTME: Gitea Actions runner for CI/CD pipelines. +# ABOUTME: Runs containerized actions with Docker-in-Docker support. + +# Setup required before running: +# sudo mkdir -p /data/services/act-runner +# nomad var put secrets/act-runner registration_token="" + +job "act-runner" { + datacenters = ["alo"] + type = "service" + + group "runner" { + network { + mode = "host" + } + + task "runner" { + driver = "docker" + + config { + image = "gitea/act_runner:latest" + network_mode = "host" + privileged = true + volumes = [ + "/var/run/docker.sock:/var/run/docker.sock", + "/data/services/act-runner:/data", + "local/config.yaml:/.runner/config.yaml", + ] + } + + template { + destination = "local/config.yaml" + data = <