Repository navigation
fix(ci): forward flake shellHook env in direnv preamble - #1183
Merged
Merged
Conversation
Add executed-bash coverage for the setup-devkit-toolchain direnv step: a stubbed nix emits a simulated dev-shell environment, and the test asserts shellHook exports reach GITHUB_ENV (scalar + multi-line heredoc) while shell session state and Nix/stdenv build machinery stay denied and unchanged ambient vars are never re-forwarded. Fails today because the step forwards PATH only. Refs: #1180
The direnv-mode setup-devkit-toolchain step exported the dev-shell store bin dirs to GITHUB_PATH but dropped everything the flake shellHook exports, so env defaults present in every local nix develop/direnv session silently vanished on CI (vig-os/org-config#40). Diff the ambient environment against the dev-shell environment (the shellHook has run inside nix develop) and forward the vars the dev-shell adds or changes to GITHUB_ENV, minus a denylist of shell session state and Nix/stdenv build machinery. Null-delimited env dumps plus a random GITHUB_ENV heredoc delimiter keep multi-line values intact; the ambient diff keeps host secrets out of GITHUB_ENV. Refs: #1180
Add the Unreleased changelog entry (synced to the .devcontainer mirror) and a MIGRATION.md subsection describing the default shellHook env forwarding, the ambient diff that keeps host secrets out of GITHUB_ENV, the session/build machinery denylist, and why the diff-plus-denylist approach beats forwarding nix print-dev-env wholesale. Refs: #1180
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #1180. In direnv mode the
setup-devkit-toolchainpreamble exported thedev-shell store bin dirs to
GITHUB_PATHbut dropped everything a project'sflake
shellHookexports, so env defaults present in every localnix develop/direnv session silently vanished on CI — a local-vs-CI divergencethat surfaced as unrelated tool errors (vig-os/org-config#40: a shellHook-seeded
OTTERDOG_TOKENplaceholder worked locally, failed on CI).The preamble now forwards the flake
shellHookenvironment to CI by default,sanitized (the approved design).
Approach — env-diff + denylist
env -0) and the dev-shell env(
nix develop --command env -0, so theshellHookhas already run), bothnull-delimited so newlines/special chars survive.
diff is the security boundary — host secrets already in the runner env are
unchanged inside the shell, so they are never re-emitted into
GITHUB_ENV.PATH— already handled viaGITHUB_PATH—HOME,USER,LOGNAME,SHELL,TERM,PWD,OLDPWD,SHLVL,IFS,TMPDIR/TMP/TEMP/TEMPDIR) or Nix/stdenv build machinery(
NIX_*,out,outputs,src,stdenv,system,builder,name,pname,version,shell,shellHook,buildInputs,nativeBuildInputs,propagated*BuildInputs,deps*,*Phase,phases,dont*,configureFlags/cmakeFlags/mesonFlags/makeFlags,patches,strictDeps,SOURCE_DATE_EPOCH,HOST_PATH,outputHash*, …).GITHUB_ENVheredoc delimiter, somulti-line and special-character values cannot break
GITHUB_ENVparsing.Why env-diff, not
nix print-dev-envnix print-dev-envdumps the full stdenv build machinery (phases, buildInputs,stdenv, out, …), none of which belongs in a CI environment — separating a
project's genuine
shellHookexports from that noise still needs a diff and adenylist. The env-diff (outside vs inside the dev shell) isolates exactly the
dev-shell's contribution, and the denylist removes the build machinery that the
shell layers on top. Cleaner and more robust than parsing print-dev-env.
Contained to the direnv step (
if: inputs.mode == 'direnv'); container and baremodes are untouched.
Tests / evidence
New
tests/test_setup_toolchain_env.pyexecutes the step's realrun:script against a stubbed
nixthat emits a simulated dev-shell env (sameexecuted-bash pattern as
test_ci_runner.py):OTTERDOG_TOKEN,PROJECT_GREETING) reachGITHUB_ENV;boundary).
18 passed; fullprek run --all-filesgreen; manual shellcheck of the step'srun script clean (only pre-existing SC2016 info notes on the existing
single-quoted
nix developcaptures).Scope
Minimal diff: the direnv step, a new test, changelog (+ synced
.devcontainermirror), and a MIGRATION.md subsection. The LD_LIBRARY_PATH/native-wheel issue
(#1181) is deliberately untouched;
justfile.baseuntouched.Refs: #1180, vig-os/org-config#40