Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

ci(tend-setup): install Nix so the weekly bot can refresh flake.lock (#3891)

Maximilian Roos2960bfba2aaf
diff --git a/.claude/skills/running-tend/SKILL.md b/.claude/skills/running-tend/SKILL.md
index d998759f5..ceb43a353 100644
--- a/.claude/skills/running-tend/SKILL.md
+++ b/.claude/skills/running-tend/SKILL.md
@@ -44,11 +44,9 @@ If codecov fails **locally**, investigate with `task coverage` and
`task` and `cargo-llvm-cov` are not installed in the `tend-setup` action.
Don't try to `cargo install` them in the sandbox — past attempts at
source-compiling installs cascaded into bash-tool interrupts that blocked
-even `pwd` and `echo`. (Pre-built single-script installers like Determinate
-Nix's are fine — see **Weekly Maintenance: MSRV & Toolchain** for the one we
-use. The block is specifically about long-running cargo compiles.) Instead,
-query Codecov directly, following `tests/CLAUDE.md` → **Coverage
-Investigation** for the endpoints and their traps.
+even `pwd` and `echo`. Instead, query Codecov directly, following
+`tests/CLAUDE.md` → **Coverage Investigation** for the endpoints and their
+traps.
If the Codecov API markers aren't enough, download the `code-coverage-report`
artifact from the PR head's `coverage` workflow run — it contains a
@@ -271,23 +269,19 @@ Files to update:
`flake.nix` reads the channel from `rust-toolchain.toml`, so no separate bump
is needed. After updating the toolchain, refresh `flake.lock` so the locked
-`rust-overlay` revision knows about the new version. Nix isn't installed in
-the tend sandbox by default — install it with the Determinate Systems
-installer (single script, daemon-mode, no prompts), then update:
+`rust-overlay` revision knows about the new version. `tend-setup` installs Nix
+with flakes enabled:
```bash
-curl -fsSL https://install.determinate.systems/nix -o /tmp/nix-installer.sh
-sh /tmp/nix-installer.sh install --no-confirm --determinate
-. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
-nix flake update --extra-experimental-features 'nix-command flakes'
+# Name the input: a bare `nix flake update` also relocks nixpkgs, an
+# unrelated bump in a toolchain-scoped PR.
+nix flake update rust-overlay
+# Check the bumped channel still evaluates
+nix eval .#devShells.x86_64-linux.default.name
```
-Verify the new lock evaluates with the channel bump before committing:
-
-```bash
-nix eval --extra-experimental-features 'nix-command flakes' \
- .#devShells.x86_64-linux.default.name
-```
+If `nix` isn't on the PATH, `tend-setup` regressed. Say so in the PR and leave
+`flake.lock` alone rather than hand-computing an entry.
Commit `flake.lock` alongside the other toolchain changes. After bumping, run
the full test suite (`cargo run -- hook pre-merge --yes`) and verify
diff --git a/.github/actions/tend-setup/action.yaml b/.github/actions/tend-setup/action.yaml
index c308b2cb9..1daad6ee2 100644
--- a/.github/actions/tend-setup/action.yaml
+++ b/.github/actions/tend-setup/action.yaml
@@ -76,3 +76,41 @@ runs:
run: |
sudo timeout -k 30 300 apt-get update
sudo timeout -k 30 300 apt-get install -y zsh fish
+
+ # Nix, for the weekly toolchain bump's `flake.lock` refresh. The sandboxed
+ # agent can't install it: that user has no sudo, so it can't create /nix.
+ # Installed here as `runner`, /nix/var/nix/profiles/default/bin lands on
+ # $GITHUB_PATH, and tend carries system PATH entries into the sandbox
+ # verbatim (only runner-home entries are rewritten), so the agent gets
+ # `nix`. ~4 s, so it isn't worth gating to the one workflow that needs it.
+ - name: Install Nix
+ uses: cachix/install-nix-action@v31
+ with:
+ extra_nix_config: |
+ experimental-features = nix-command flakes
+
+ - name: Strip the job token from /etc/nix/nix.conf
+ shell: bash
+ # The step above writes `access-tokens = github.com=<job token>` into
+ # world-readable /etc/nix/nix.conf whenever it can see a token, and its
+ # action.yml passes `GITHUB_TOKEN: ${{ github.token }}` unconditionally.
+ # `github_access_token: ""` doesn't suppress it; install-nix.sh falls
+ # through to the job token, which on tend-weekly carries `contents:
+ # write`. Deleting the line here is enough, because the sandbox user
+ # doesn't exist until the tend action runs.
+ #
+ # Nothing is lost: tend's proxy overwrites `Authorization` on every
+ # sandbox request to github.com, codeload.github.com, and api.github.com
+ # with the bot's token, so flake fetches still authenticate.
+ #
+ # The `grep` runs under sudo like the `sed`, though the file is
+ # world-readable today: `grep` exits 2 when it can't read a file, and an
+ # `if` condition takes that as "no match", so a check that couldn't run
+ # would report success. After `sed -i` succeeds, root can read the file
+ # by construction.
+ run: |
+ sudo sed -i '/^access-tokens/d' /etc/nix/nix.conf
+ if sudo grep -q 'access-tokens' /etc/nix/nix.conf; then
+ echo "::error::a GitHub token survived in /etc/nix/nix.conf"
+ exit 1
+ fi