Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/pullfrog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,30 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
with:
determinate: false
# The agent's shell can reach the daemon and read /etc/nix and
# /nix/receipt.json: keep the job's token out of both, and keep the
# runner user untrusted, since a trusted user's settings, such as a
# post-build-hook, run as root.
github-token: ""
trust-runner-user: false
- name: Put the dev shell's tools on PATH
# bash, not the default shell, for pipefail: a failing print-dev-env
# must fail the step, not write an empty PATH.
shell: bash
env:
# Authenticated fetches of the flake's inputs, for this step only.
NIX_CONFIG: access-tokens = github.com=${{ github.token }}
TOKEN: ${{ github.token }}
run: |
nix print-dev-env --json |
jq -r '.variables.PATH.value' |
tr ':' '\n' | grep '^/nix/store/' | paste -sd: >>"$GITHUB_PATH"
# The installer wrote the job's token into world-readable nix.conf and
# nix.custom.conf, and into /nix/receipt.json's plan, where the agent's
# shell could read it.
- name: Remove the job token from Nix's config
env:
TOKEN: ${{ github.token }}
run: |
sudo find /etc/nix -type f -exec sed -i '/^access-tokens/d' {} +
sudo chmod 0600 /nix/receipt.json
if sudo grep -rqF "$TOKEN" /etc/nix; then
echo "the job token is still under /etc/nix" >&2
if sudo grep -rqF "$TOKEN" /etc/nix /nix/receipt.json; then
echo "the job token reached Nix's config" >&2
exit 1
fi
Comment thread
kixelated marked this conversation as resolved.
Resolved
if ! nix store info --json | jq -e '.trusted == false or .trusted == 0' >/dev/null; then
echo "the Nix daemon trusts the runner user" >&2
exit 1
fi
- name: Run agent
Expand Down
6 changes: 4 additions & 2 deletions quest/m0/pullfrog-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ so their `pullfrog.yml` gains steps before the agent
under `Waiting`): install Nix, put the `/nix/store` entries of `main`'s
`nix print-dev-env` `PATH` on `GITHUB_PATH` (Pullfrog's restricted shell
keeps `PATH` but drops other dev-shell variables, so `nix develop --command`
stays the way to anything needing them), and delete the job token the
installer writes into `/etc/nix/nix.conf`, failing if it remains. The
stays the way to anything needing them), and keep the job's token and Nix
daemon trust from the agent: the installer gets no token and leaves the
runner user untrusted, the PATH step alone fetches with the token, and the
job fails if the token reached Nix's config. The
`pullfrog` environment admits only `main`, so these steps always build the
default branch's shell; `checkout_pr` moves to a PR's head only afterwards,
and `quest context`, now on the agent's PATH, carries the rule against
Expand Down
Loading