Skip to content

Commit f84a892

Browse files
authored
Merge pull request #158 from tinyland-inc/feat/custom-nix-runner-image
feat(runners): custom Nix runner image with xz-utils baked in
2 parents 6a528fa + f46676e commit f84a892

File tree

4 files changed

+76
-11
lines changed

4 files changed

+76
-11
lines changed

.github/actions/nix-job/action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ inputs:
1818
runs:
1919
using: "composite"
2020
steps:
21-
- name: Install Nix prerequisites
22-
if: runner.environment != 'github-hosted'
23-
shell: bash
24-
run: |
25-
if ! command -v xz &>/dev/null; then
26-
sudo apt-get update -qq && sudo apt-get install -y -qq xz-utils
27-
fi
28-
2921
- uses: cachix/install-nix-action@v30
3022
with:
3123
nix_path: nixpkgs=channel:nixos-24.11

.github/workflows/build-image.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- ".npmrc"
1313
- "app/Dockerfile"
1414
- "app/caddy/Dockerfile"
15+
- "runners/Dockerfile.nix"
1516
workflow_dispatch:
1617

1718
permissions:
@@ -114,3 +115,50 @@ jobs:
114115

115116
- name: Sign image with cosign (keyless)
116117
run: cosign sign --yes ghcr.io/tinyland-inc/caddy-tailscale@${{ steps.build-caddy.outputs.digest }}
118+
119+
nix-runner:
120+
name: Build Nix Runner
121+
runs-on: ubuntu-latest
122+
steps:
123+
- uses: actions/checkout@v4
124+
125+
- name: Log in to GHCR
126+
uses: docker/login-action@v3
127+
with:
128+
registry: ghcr.io
129+
username: ${{ github.actor }}
130+
password: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Set up Docker Buildx
133+
uses: docker/setup-buildx-action@v3
134+
135+
- name: Build and push
136+
id: build-nix-runner
137+
uses: docker/build-push-action@v6
138+
with:
139+
context: runners
140+
file: runners/Dockerfile.nix
141+
push: true
142+
tags: |
143+
ghcr.io/tinyland-inc/actions-runner-nix:latest
144+
ghcr.io/tinyland-inc/actions-runner-nix:${{ github.sha }}
145+
cache-from: type=gha
146+
cache-to: type=gha,mode=max
147+
labels: |
148+
org.opencontainers.image.source=https://github.com/tinyland-inc/GloriousFlywheel
149+
org.opencontainers.image.description=GitHub Actions runner with Nix prerequisites (xz, curl, git, jq)
150+
151+
- name: Scan image for vulnerabilities
152+
uses: aquasecurity/trivy-action@master
153+
with:
154+
image-ref: ghcr.io/tinyland-inc/actions-runner-nix:${{ github.sha }}
155+
format: table
156+
exit-code: "1"
157+
severity: CRITICAL
158+
ignore-unfixed: true
159+
160+
- name: Install cosign
161+
uses: sigstore/cosign-installer@v3
162+
163+
- name: Sign image with cosign (keyless)
164+
run: cosign sign --yes ghcr.io/tinyland-inc/actions-runner-nix@${{ steps.build-nix-runner.outputs.digest }}

runners/Dockerfile.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Custom ARC runner image for Nix workloads
2+
#
3+
# Extends the official GitHub Actions runner with tools needed for
4+
# Nix builds on our self-hosted Civo runner pool. No runtime apt-get
5+
# calls to external repos — everything baked in.
6+
#
7+
# Tools added:
8+
# - xz-utils (NAR compression, required by nix-installer-action)
9+
# - curl, git, jq (common CI utilities)
10+
# - ca-certificates (TLS for Attic cache)
11+
12+
FROM ghcr.io/actions/actions-runner:latest
13+
14+
USER root
15+
16+
RUN apt-get update -qq \
17+
&& apt-get install -y -qq --no-install-recommends \
18+
xz-utils \
19+
curl \
20+
git \
21+
jq \
22+
ca-certificates \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
USER runner

tofu/modules/arc-runner/locals.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ locals {
99

1010
# Default images per runner type
1111
# The runner image must include the GH Actions runner agent (/home/runner/run.sh).
12-
# For nix runners, we use a custom image with Nix + xz pre-installed so that
13-
# cachix/install-nix-action and nix-installer-action both work without extra deps.
12+
# Nix runners use our custom image with xz-utils, curl, git, jq baked in so that
13+
# cachix/install-nix-action works without runtime apt-get calls to external repos.
1414
runner_type_images = {
1515
docker = "ghcr.io/actions/actions-runner:latest"
1616
dind = "ghcr.io/actions/actions-runner:latest"
17-
nix = "ghcr.io/actions/actions-runner:latest"
17+
nix = "ghcr.io/tinyland-inc/actions-runner-nix:latest"
1818
}
1919

2020
# Tool images used as init containers to provide tooling (Nix store, etc.)

0 commit comments

Comments
 (0)