Skip to content

fix(ci): extend runner host Nix configuration - #1916

Merged
gerchowl merged 7 commits into
devfrom
bugfix/1907-nix-config-extend
Oct 26, 2026
Merged

gerchowl merged 7 commits into
devfrom
bugfix/1907-nix-config-extend

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Preserve a self-hosted runner's valid ambient NIX_CONFIG when configuring preinstalled host Nix in direnv mode. Runner caches, keys, experimental features and CPU limits survive into subsequent steps. Reject malformed configuration with a warning that never includes diagnostic values or access tokens. Register masks for accepted ambient access tokens and potentially credential-bearing URL values before exporting them, so later step environment headers cannot expose them.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • Register one add-mask for every token on every ambient access-tokens line before the first GITHUB_ENV write; escape workflow-command data. Mask URL values with userinfo or query parameters as well. The Nix settings reference identifies netrc-file and secret-key-files as paths, so their file contents are never exported.

  • Probe command support without ambient NIX_CONFIG: use nix config show when available, otherwise nix show-config (including Nix 2.18). If neither command works, fail explicitly rather than label the ambient value malformed.

  • Validate with the selected command, preserving accepted ambient config ahead of devkit's lines. Rejected config produces a generic warning with diagnostic values redacted. Select a heredoc delimiter absent from the value.

  • Enumerated settings: extra-experimental-features, extra-substituters, and extra-trusted-public-keys add to runner lists. accept-flake-config = true deliberately remains owned by devkit: the toolchain must accept the consumer repository flake's cache configuration. Devkit writes no CPU limits or replacement cache lists.

  • Share expected values in the tests with explicit install/host feature keys, and compare whole URL sets. Document behavior in the self-hosted migration section. There is no devkit-owned .github/actions/setup-devkit-toolchain copy to update.

Changelog Entry

Fixed

  • Preserve runner Nix configuration in the toolchain action (#1907)
    • With preinstalled host Nix in direnv mode, preserve valid ambient NIX_CONFIG, including runner caches and CPU limits, and add devkit's features and cache settings; extra-experimental-features extends the host nix.conf feature list instead of replacing it
    • Mask ambient access tokens and URL values containing userinfo or queries before export so later step environment headers do not expose credentials
    • Validate with the command supported by host Nix (including show-config before Nix 2.20); fail explicitly if neither command is available. Drop malformed ambient configuration with a warning that redacts diagnostic values; keep the exported configuration valid and the environment delimiter collision-safe

Testing

  • Tests pass locally (targeted suites below; no full local suite)
  • Manual testing performed (describe below)

Manual Testing Details

  • RED before initial implementation: 3 failed, 2 passed (exit 1); failing tests committed first.
  • RED round two: nix develop --command uv run --with pytest-xdist pytest tests/test_setup_toolchain_env.py -k 'validation or malformed_token' -n 4 --basetemp="$HOME/.cache/devkit-pytest/1907-r2" exited 1: 4 failed, 2 passed; failing tests committed first.
  • RED round three: nix develop --command uv run --with pytest-xdist pytest tests/test_setup_toolchain_env.py -k masks_credentials -n 4 --basetemp="$HOME/.cache/devkit-pytest/1907-r3" exited 1: both credential-mask regressions failed before implementation; failing tests committed first. The test validates the ambient input with real Nix and observes that mask commands precede the first environment-file write.
  • GREEN round three: nix develop --command uv run --with pytest-xdist pytest tests/test_setup_toolchain_env.py tests/test_workflow_devkit_upgrade.py tests/test_scaffold_drift.py -n 4 --basetemp="$HOME/.cache/devkit-pytest/1907-r3" exited 0: 112 passed.
  • GREEN round two: nix develop --command uv run --with pytest-xdist pytest tests/test_setup_toolchain_env.py tests/test_workflow_devkit_upgrade.py tests/test_scaffold_drift.py -n 4 --basetemp="$HOME/.cache/devkit-pytest/1907-r2" exited 0: 110 passed.
  • Post-rebase targeted rerun exited 1: 111 passed; the existing scaffold-drift clone test failed with fatal: failed to copy file ... .git/objects/99/ef67180523274a572a087c52216bf697f891aa: No such file or directory. Disk usage was 6%; no cache/store cleanup or test changes were made. CI is the full-suite authority per the task brief.
  • Actual step execution and real Nix verify exported runner cache/key, cores = 2, max-jobs = 3, ambient features and devkit settings. Coverage includes empty/unset input, modern/legacy validation, unavailable validator, redaction of malformed token config and delimiter collisions.
  • --with pytest-xdist supplies the missing local dependency. Commit hooks run inside nix develop, including scaffold changelog synchronization.

CI on a53cc1b4778bbcfb8cb87ab11283e3b989c5ef02: all 16 checks pass, including CodeQL, Project Tests, Project Flake Gates, container/integration suites, both security scans and Test Summary. gh pr checks 1916 --watch exited 0. The passing CI run is authoritative over the local post-rebase Git object-copy failure noted above.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (MIGRATION.md has no generated template)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

On multi-user Nix, cache entries still require a trusted user, as documented in the existing action comment. Container and flake-evaluation suites are left to CI per the task brief.

Refs: #1907

Comment thread tests/test_setup_toolchain_env.py Fixed
Comment thread tests/test_setup_toolchain_env.py Fixed
Comment thread tests/test_setup_toolchain_env.py Fixed
Comment thread tests/test_setup_toolchain_env.py Fixed
Comment thread tests/test_setup_toolchain_env.py Fixed
Comment thread tests/test_setup_toolchain_env.py Fixed
@gerchowl
gerchowl force-pushed the bugfix/1907-nix-config-extend branch from 19caa67 to 2a3dd87 Compare October 26, 2026 18:48
@gerchowl
gerchowl force-pushed the bugfix/1907-nix-config-extend branch from 2a3dd87 to a53cc1b Compare October 26, 2026 19:02
@gerchowl
gerchowl merged commit 3ce1074 into dev Oct 26, 2026
16 checks passed
@gerchowl
gerchowl deleted the bugfix/1907-nix-config-extend branch October 26, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants