Repository navigation
ci: pre-commit hook sets the opensecret dev-shell knobs on nix develop - #969
Merged
Merged
Conversation
Contributor
|
Maple development preview: https://9a711643.maple-ca8.pages.dev Commit: Uses development API, billing, flags and PCR configuration. Cloudflare Access applies. |
…it hook The hook ran `nix develop ... -c env OPENSECRET_DEV_POSTGRES=0 ... sh <script>`, so the knobs reached only the check script. A flake's shellHook runs before the `-c` command, and by then the opensecret shell had already run initdb, started a PostgreSQL server on the default port from `.pgdata` in the committing checkout, and copied `.env.sample` to `.env` when absent. The server outlived the commit. Set the component environment on `nix develop` itself; it passes its environment through, so the script still sees the same values.
AnthonyRonning
force-pushed
the
ci/precommit-dev-shell-env
branch
from
September 18, 2026 17:08
ad38779 to
c16c454
Compare
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.
Summary
.githooks/pre-commitran the opensecret component asso the knobs reached only the check script.
nix developruns the flake'sshellHookbefore the-ccommand, and the opensecret shell hook defaults every knob to1. On every commit that staged backend files it therefore raninitdb, started PostgreSQL on port 5432 fromservices/opensecret/.pgdatain the committing checkout (or silently reused whatever was already listening on that port), created theopensecret_userrole andopensecretdatabase, and copied.env.sampleto.envwhen the checkout had none. The server outlived the commit and had to be found and stopped by hand. The hook's own comment,services/opensecret/AGENTS.md, and thedevelop-opensecretskill all said this does not happen.Fix:
run_componentsets the componentENV=VALUEpairs onnix developitself (env -u GIT_DIR ... OPENSECRET_DEV_POSTGRES=0 ... nix develop ... -c env MAPLE_HOOK_IN_NIX=1 sh <script>).nix developpasses its environment through, so the script sees the same values. The no-Nix path already did this and is unchanged.The other component shells (
.#ci,sdk,proxy,apps/maple-agent) only export variables or pick a cargo build directory behind their own knob, so opensecret remains the only component that passes environment through the hook.Verification
PGDATAand a spare port so nothing shared was touched). Old form: theinitdbtranscript,server started,CREATE ROLE,CREATE DATABASE,pg_isreadyaccepting connections, and a fresh.envin the checkout, while the-ccommand itself printedOPENSECRET_DEV_POSTGRES=0. New form: noinitdb, no cluster directory,pg_isready"no response", no.env, andcargostill resolves inside the shell.MAPLE_HOOK_ONLY=repo,opensecret:repo(thescripts/ciunit tests) in 20 s, then the realopensecretcomponent (cargo fmt --check, Clippy with-D warnings,cargo test: 647 passed, 0 failed, 23 ignored) in 128 s. The hook output has noinitdb/server startedlines, no.pgdata/or.envappeared in the checkout, and nothing was listening on 5432 afterwards.shellcheck -s shon.githooks/pre-commit,.githooks/lib/common.sh,.githooks/repo-checks, and the opensecret script: clean.nixthat records the environmentnix developreceives) failed against the old hook and passed with the fix. It is not part of this PR.Note
If the opensecret
devShells.defaultshellHook grows new stateful steps, they need their own knob and an entry in the hook'srun_componentcall for opensecret.🤖 Generated with Claude Code