Merge branch 'master' into frcc-kvm
diff-pr / dix (pull_request) Successful in 6m50s
flake-check / flake-check (pull_request) Failing after 2m0s
lint / lint (pull_request) Failing after 1m51s

This commit is contained in:
Floweynt
2026-09-10 11:33:34 -05:00
9 changed files with 55 additions and 62 deletions
+4 -9
View File
@@ -13,26 +13,21 @@ concurrency:
jobs: jobs:
dix: dix:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: worktree base for diff - name: worktree base for diff
run: git worktree add "$RUNNER_TEMP/base" "${{ github.event.pull_request.base.sha }}" run: git worktree add "$RUNNER_TEMP/base" "${{ github.event.pull_request.base.sha }}"
- name: build closures and render diff - name: build closures and render diff
run: | run: |
nix run .#ci -- diff "$RUNNER_TEMP/base" . \ nix run -L .#ci -- diff "$RUNNER_TEMP/base" . \
"### System closure diff vs \`${{ github.event.pull_request.base.ref }}\`" \ "### System closure diff vs \`${{ github.event.pull_request.base.ref }}\`" \
> "$RUNNER_TEMP/comment.md" > "$RUNNER_TEMP/comment.md"
nix run .#ci -- inspect-diff "$RUNNER_TEMP/base" . \ nix run -L .#ci -- inspect-diff "$RUNNER_TEMP/base" . \
"### Inspection diff vs \`${{ github.event.pull_request.base.ref }}\`" \ "### Inspection diff vs \`${{ github.event.pull_request.base.ref }}\`" \
>> "$RUNNER_TEMP/comment.md" >> "$RUNNER_TEMP/comment.md"
@@ -42,4 +37,4 @@ jobs:
API: ${{ github.api_url }} API: ${{ github.api_url }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number }} PR: ${{ github.event.pull_request.number }}
run: nix run .#ci -- post-comment "<!-- dix-diff -->" "$RUNNER_TEMP/comment.md" run: nix run -L .#ci -- post-comment "<!-- dix-diff -->" "$RUNNER_TEMP/comment.md"
+3 -8
View File
@@ -9,17 +9,12 @@ permissions:
jobs: jobs:
dix: dix:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: diff latest tag against HEAD - name: diff latest tag against HEAD
run: | run: |
tag=$(git tag --sort=-creatordate | head -n1) tag=$(git tag --sort=-creatordate | head -n1)
@@ -30,8 +25,8 @@ jobs:
git worktree add "$RUNNER_TEMP/old" "$tag" git worktree add "$RUNNER_TEMP/old" "$tag"
head=$(git rev-parse --short HEAD) head=$(git rev-parse --short HEAD)
{ {
nix run .#ci -- diff "$RUNNER_TEMP/old" . \ nix run -L .#ci -- diff "$RUNNER_TEMP/old" . \
"# System closure diff: \`$tag\` -> \`$head\`" "# System closure diff: \`$tag\` -> \`$head\`"
nix run .#ci -- inspect-diff "$RUNNER_TEMP/old" . \ nix run -L .#ci -- inspect-diff "$RUNNER_TEMP/old" . \
"# Inspection diff: \`$tag\` -> \`$head\`" "# Inspection diff: \`$tag\` -> \`$head\`"
} | tee -a "$GITHUB_STEP_SUMMARY" } | tee -a "$GITHUB_STEP_SUMMARY"
+1 -6
View File
@@ -14,13 +14,8 @@ concurrency:
jobs: jobs:
flake-check: flake-check:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix flake check -L - run: nix flake check -L
+3 -8
View File
@@ -11,16 +11,11 @@ permissions:
jobs: jobs:
update: update:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31 - run: nix flake update -L
with:
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix flake update
- name: open/update PR - name: open/update PR
env: env:
@@ -29,5 +24,5 @@ jobs:
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
run: | run: |
printf 'Automated `nix flake update`.\n' > "$RUNNER_TEMP/body.md" printf 'Automated `nix flake update`.\n' > "$RUNNER_TEMP/body.md"
nix run .#ci -- open-pr \ nix run -L .#ci -- open-pr \
flake-update "$GITHUB_REF_NAME" "flake.lock: update inputs" "$RUNNER_TEMP/body.md" automated flake-update "$GITHUB_REF_NAME" "flake.lock: update inputs" "$RUNNER_TEMP/body.md" automated
+3 -8
View File
@@ -15,15 +15,10 @@ concurrency:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: pick reporter - name: pick reporter
run: | run: |
if [ "${{ github.event_name }}" = pull_request ]; then if [ "${{ github.event_name }}" = pull_request ]; then
@@ -33,9 +28,9 @@ jobs:
fi fi
- name: run linters - name: run linters
run: nix run .#ci -- lint . "$RUNNER_TEMP/findings" run: nix run -L .#ci -- lint . "$RUNNER_TEMP/findings"
- name: report findings - name: report findings
env: env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: nix run .#ci -- lint-report "$REPORTER" "$RUNNER_TEMP/findings" run: nix run -L .#ci -- lint-report "$REPORTER" "$RUNNER_TEMP/findings"
+4 -9
View File
@@ -11,18 +11,13 @@ permissions:
jobs: jobs:
scan: scan:
runs-on: ubuntu-latest runs-on: nix
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: scan host closures - name: scan host closures
id: scan id: scan
run: echo "count=$(nix run .#ci -- vulnix . "$RUNNER_TEMP/issue.md")" >> "$GITHUB_OUTPUT" run: echo "count=$(nix run -L .#ci -- vulnix . "$RUNNER_TEMP/issue.md")" >> "$GITHUB_OUTPUT"
- name: file/update issue - name: file/update issue
if: steps.scan.outputs.count != '0' if: steps.scan.outputs.count != '0'
@@ -30,7 +25,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.api_url }} API: ${{ github.api_url }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
run: nix run .#ci -- upsert-issue vulnix "vulnix: known vulnerabilities in system closure" "$RUNNER_TEMP/issue.md" run: nix run -L .#ci -- upsert-issue vulnix "vulnix: known vulnerabilities in system closure" "$RUNNER_TEMP/issue.md"
- name: close resolved issue - name: close resolved issue
if: steps.scan.outputs.count == '0' if: steps.scan.outputs.count == '0'
@@ -38,4 +33,4 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.api_url }} API: ${{ github.api_url }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
run: nix run .#ci -- close-issue vulnix run: nix run -L .#ci -- close-issue vulnix
+1 -1
View File
@@ -17,7 +17,7 @@ def run(*args, **kw):
def nix(*args): def nix(*args):
return run("nix", "--extra-experimental-features", "nix-command flakes", *args, check=True, capture_output=True).stdout return run("nix", "--extra-experimental-features", "nix-command flakes", "-L", *args, check=True, stdout=subprocess.PIPE).stdout
def git(*args, check=True): def git(*args, check=True):
+34 -13
View File
@@ -8,6 +8,9 @@ let
inherit (dsl) mkContainer mkVm; inherit (dsl) mkContainer mkVm;
inherit (hostInfo.paths) data secrets; inherit (hostInfo.paths) data secrets;
pubSshPort = 23;
intSshPort = 23 + 8000;
ciRunnerData = "${data}/web/git-ci-runner"; ciRunnerData = "${data}/web/git-ci-runner";
ciRunnerSecrets = "${secrets}/ci-runner"; ciRunnerSecrets = "${secrets}/ci-runner";
in in
@@ -17,8 +20,8 @@ in
net.access = [ { to = "@internet"; } ]; net.access = [ { to = "@internet"; } ];
net.forward.tcp = [ net.forward.tcp = [
{ {
host = 23; host = pubSshPort;
container = 8023; container = intSshPort;
} }
]; ];
svc.autoStart = true; svc.autoStart = true;
@@ -38,7 +41,8 @@ in
ROOT_URL = "https://git.floweytf.com/"; ROOT_URL = "https://git.floweytf.com/";
START_SSH_SERVER = true; START_SSH_SERVER = true;
BUILTIN_SSH_SERVER_USER = "git"; BUILTIN_SSH_SERVER_USER = "git";
SSH_PORT = 8023; SSH_PORT = pubSshPort;
SSH_LISTEN_PORT = intSshPort;
}; };
service.DISABLE_REGISTRATION = true; service.DISABLE_REGISTRATION = true;
}; };
@@ -53,6 +57,7 @@ in
ci-runner = mkVm { ci-runner = mkVm {
name = "ci-runner"; name = "ci-runner";
includedInTests = false;
net.access = [ net.access = [
{ {
to = "git"; to = "git";
@@ -62,7 +67,7 @@ in
]; ];
svc.autoStart = true; svc.autoStart = true;
resources.cpu = 4; resources.cpu = 4;
resources.mem = "8G"; resources.mem = "32G";
resources.fs = [ resources.fs = [
{ {
proto = "virtiofs"; proto = "virtiofs";
@@ -80,7 +85,7 @@ in
proto = "virtiofs"; proto = "virtiofs";
tag = "runner-state"; tag = "runner-state";
source = "${ciRunnerData}/runner-state"; source = "${ciRunnerData}/runner-state";
mountPoint = "/var/lib/gitea-runner"; mountPoint = "/var/lib/private/gitea-runner";
} }
{ {
proto = "virtiofs"; proto = "virtiofs";
@@ -100,20 +105,24 @@ in
let let
runnerInstanceName = "ci-runner"; runnerInstanceName = "ci-runner";
ciJobContents = with pkgs; [
bashInteractive
coreutils
gitMinimal
nixVersions.latest
nodejs
cacert
(writeTextDir "etc/nix/nix.conf" "experimental-features = nix-command flakes\n")
];
ciJobImage = pkgs.dockerTools.buildLayeredImage { ciJobImage = pkgs.dockerTools.buildLayeredImage {
name = "ci-job-image"; name = "ci-job-image";
tag = "latest"; tag = "latest";
contents = with pkgs; [ contents = ciJobContents;
bashInteractive
coreutils
gitMinimal
nixVersions.latest
nodejs
cacert
];
config = { config = {
Cmd = [ "/bin/sh" ]; Cmd = [ "/bin/sh" ];
Env = [ Env = [
"PATH=${lib.makeBinPath ciJobContents}"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" "NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"NIX_REMOTE=daemon" "NIX_REMOTE=daemon"
@@ -125,6 +134,10 @@ in
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModprobeConfig = "options kvm_intel nested=1"; boot.extraModprobeConfig = "options kvm_intel nested=1";
# volume-mounted into CI containers; must be in VM's store so
# image symlinks (/bin/node etc.) resolve through the mount
system.extraDependencies = ciJobContents;
microvm.writableStoreOverlay = "/nix/.rw-store"; microvm.writableStoreOverlay = "/nix/.rw-store";
nix.settings = { nix.settings = {
@@ -142,7 +155,15 @@ in
}; };
# nix.optimise.automatic = true; - doesn't work with microvm.writableStoreOverlay # nix.optimise.automatic = true; - doesn't work with microvm.writableStoreOverlay
services.journald.extraConfig = "ForwardToConsole=yes";
virtualisation.containerd.enable = true;
virtualisation.containerd.settings.plugins."io.containerd.snapshotter.v1.overlayfs".mount_options = [ "userxattr" ];
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
virtualisation.docker.extraOptions = "--containerd /run/containerd/containerd.sock";
systemd.services.docker.wants = [ "containerd.service" ];
systemd.services.docker.after = [ "containerd.service" ];
systemd.services.load-ci-job-image = { systemd.services.load-ci-job-image = {
description = "Load the CI job Docker image"; description = "Load the CI job Docker image";
+2
View File
@@ -571,6 +571,8 @@ rec {
Destination = "0.0.0.0/0"; Destination = "0.0.0.0/0";
Gateway = hostAddr; Gateway = hostAddr;
}; };
networkConfig.DNS = [ hostAddr ];
networkConfig.Domains = [ "~." "containers" ];
linkConfig.RequiredForOnline = if allowInternet then "routable" else "degraded"; linkConfig.RequiredForOnline = if allowInternet then "routable" else "degraded";
}; };
networking.enableIPv6 = false; networking.enableIPv6 = false;