Skip to content

Commit 230e34d

Browse files
kixelatedclaude
andauthored
ci: move Nix workflows to the self-hosted ARM runner + warm cache for aarch64-linux (#1793)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9862540 commit 230e34d

6 files changed

Lines changed: 67 additions & 25 deletions

File tree

.github/actionlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Custom labels for the moq-dev self-hosted A1 runner, so actionlint accepts
2+
# `runs-on: [self-hosted, nix]`. `self-hosted` is built in; `nix` is ours.
3+
self-hosted-runner:
4+
labels:
5+
- nix

.github/workflows/cachix.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@ jobs:
1515
# (e.g. moq-relay) maps 1:1 to a flake attribute.
1616
release:
1717
name: Release (${{ matrix.os }})
18-
runs-on: ${{ matrix.os }}
18+
runs-on: ${{ matrix.runs-on }}
1919
permissions:
2020
contents: read
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
os:
25-
- ubuntu-latest
26-
- macos-latest
24+
include:
25+
# `os` is just the cache pin label; keep the existing values stable so
26+
# old pins aren't orphaned.
27+
- os: ubuntu-latest # x86_64-linux
28+
runs-on: ubuntu-latest
29+
- os: macos-latest # aarch64-darwin
30+
runs-on: macos-latest
31+
# aarch64-linux on the moq-dev self-hosted A1 (warm /nix/store). Tag
32+
# pushes are trusted, so no fork concern.
33+
- os: aarch64-linux
34+
runs-on: [self-hosted, nix]
2735

2836
steps:
2937
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
@@ -45,14 +53,29 @@ jobs:
4553
fi
4654
echo "name=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
4755
48-
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
56+
# The cachix action and `nix build` below run `nix` directly, so put it on
57+
# PATH. A login shell resolves it via /etc/profile.d regardless of the
58+
# box's install path. Self-hosted only; the hosted runners get Nix from
59+
# the installer step.
60+
- name: Add Nix to PATH
61+
if: runner.environment == 'self-hosted'
62+
shell: bash -leo pipefail {0}
63+
run: dirname "$(command -v nix)" >> "$GITHUB_PATH"
64+
65+
- if: runner.environment == 'github-hosted'
66+
uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
4967
with:
5068
determinate: false
5169

5270
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
5371
with:
5472
name: kixelated
5573
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
74+
# The self-hosted box's runner user isn't a Nix trusted-user and the
75+
# box deliberately substitutes only from its warm local store, so
76+
# don't let `cachix use` rewrite nix.conf there. Push auth (above)
77+
# still works; this leg only pushes.
78+
skipAddingSubstituter: ${{ runner.environment == 'self-hosted' }}
5679

5780
- name: Build and cache
5881
env:

.github/workflows/release-js.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@ concurrency:
1818
jobs:
1919
release:
2020
name: Release JS Packages
21-
runs-on: ubuntu-latest
21+
# Trusted push to main, so run on the moq-dev self-hosted A1 runner (warm
22+
# /nix/store).
23+
runs-on: [self-hosted, nix]
2224
if: github.repository_owner == 'moq-dev'
2325

2426
steps:
2527
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
2628
with:
2729
persist-credentials: false
2830

29-
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
30-
with:
31-
determinate: false
32-
3331
- name: Setup npm registry
3432
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
3533
with:
3634
registry-url: 'https://registry.npmjs.org'
3735

36+
# Login shell so /etc/profile.d puts Nix on PATH; Actions shells don't by
37+
# default.
3838
- name: Install dependencies
3939
run: nix develop --command bun install --frozen-lockfile
40+
shell: bash -leo pipefail {0}
4041

4142
- name: Release packages
4243
# Web-component packages register custom elements via global type
@@ -45,3 +46,4 @@ jobs:
4546
env:
4647
JSR_ALLOW_SLOW_TYPES: "true"
4748
run: nix develop --command bun --filter '*' release
49+
shell: bash -leo pipefail {0}

.github/workflows/release-py.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ concurrency:
3131
jobs:
3232
build:
3333
name: Build wheel + sdist
34-
runs-on: ubuntu-latest
34+
# Trusted push to main and the wrapper wheel is pure-python (arch
35+
# independent), so run on the moq-dev self-hosted A1 runner (warm
36+
# /nix/store).
37+
runs-on: [self-hosted, nix]
3538
if: ${{ github.repository_owner == 'moq-dev' }}
3639
outputs:
3740
version: ${{ steps.version.outputs.version }}
@@ -56,12 +59,11 @@ jobs:
5659
VERSION: ${{ steps.version.outputs.version }}
5760
run: .github/scripts/release.sh pypi-exists moq-rs "$VERSION"
5861

59-
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
60-
with:
61-
determinate: false
62-
62+
# Login shell so /etc/profile.d puts Nix on PATH; Actions shells don't by
63+
# default.
6364
- name: Build
6465
run: nix develop --command just py package
66+
shell: bash -leo pipefail {0}
6567

6668
- name: Upload artifacts
6769
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7

.github/workflows/release-rs.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ jobs:
1818
release:
1919
name: Plz
2020

21-
runs-on: ubuntu-latest
21+
# Trusted push to main, so run on the moq-dev self-hosted A1 runner (warm
22+
# /nix/store + persistent CARGO_TARGET_DIR).
23+
runs-on: [self-hosted, nix]
2224
if: ${{ github.repository_owner == 'moq-dev' }}
2325

2426
steps:
@@ -37,13 +39,16 @@ jobs:
3739
fetch-depth: 0
3840
token: ${{ steps.generate-token.outputs.token }}
3941

40-
# Install Nix for system dependencies (e.g. ffmpeg)
41-
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
42-
with:
43-
determinate: false
42+
# Persist the cargo target outside the workspace (checkout clean wipes the
43+
# workspace, not $HOME). Scope per runner so a second service on the box
44+
# gets its own dir instead of racing on a shared one.
45+
- run: echo "CARGO_TARGET_DIR=$HOME/cargo-target/moq-$RUNNER_NAME" >> "$GITHUB_ENV"
4446

47+
# Login shell so /etc/profile.d puts Nix on PATH; Actions shells don't by
48+
# default.
4549
- name: Release
4650
run: nix develop --command just rs release
51+
shell: bash -leo pipefail {0}
4752
env:
4853
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
4954
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/update-flake.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@ on:
1212
jobs:
1313
update-flake:
1414
name: Update flake.lock
15-
runs-on: ubuntu-latest
15+
# Run on the moq-dev self-hosted A1 runner (already has Nix); fork dispatches
16+
# have no such runner, so guard on the owner to avoid queueing forever.
17+
runs-on: [self-hosted, nix]
18+
if: ${{ github.repository_owner == 'moq-dev' }}
1619

1720
steps:
1821
- name: Checkout
1922
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
2023

21-
- name: Install Nix
22-
uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
23-
with:
24-
determinate: false
24+
# The update-flake-lock action runs `nix` directly (not through a shell),
25+
# so put Nix on GITHUB_PATH. A login shell resolves it via /etc/profile.d
26+
# regardless of the box's install path.
27+
- name: Add Nix to PATH
28+
shell: bash -leo pipefail {0}
29+
run: dirname "$(command -v nix)" >> "$GITHUB_PATH"
2530

2631
- name: Update flake.lock
2732
uses: DeterminateSystems/update-flake-lock@b83e0671a67dfd774680fb1beaa1497ef7e58bfc # main

0 commit comments

Comments
 (0)