Skip to content

chore: unify CLI and backend on a single nixpkgs pin - #303

Open
FrameAutomata wants to merge 1 commit into
chore/nix-dev-shellsfrom
chore/unify-nixpkgs-input
Open

chore: unify CLI and backend on a single nixpkgs pin#303
FrameAutomata wants to merge 1 commit into
chore/nix-dev-shellsfrom
chore/unify-nixpkgs-input

Conversation

@FrameAutomata

@FrameAutomata FrameAutomata commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #302. Base is chore/nix-dev-shells, not main — merge that first.

Why

cli/flake.nix and the root flake declared the identical input (github:NixOS/nixpkgs/nixos-unstable) but carried locks generated ~94 days apart, so the CLI built against go 1.26.3 and the backend against 1.26.5.

Two sibling flakes cannot share a lock — follows only redirects a flake's own transitive inputs, and a path:.. input would copy the whole tracked repo into the store. So the CLI's flake is removed and cli/.envrc targets the root flake's cli shell.

The ~60 existing call sites keep working

Nix resolves a bare nix develop up to the enclosing git root (verified). So cli/README.md, docs/pages/learn/cli.mdx, the plan docs, and cli/.claude/skills/integration-test/SKILL.md need no edits. gomodifytags and impl move into the root shell so it stays a superset rather than a downgrade.

cli/README.md is updated to prefer nix develop ..#cli, and notes that a bare nix develop still works but lands in the heavier default shell.

The cli shell is its own derivation

It carries the same packages as backend, but aliasing would make it announce itself as "backend" and print backend run commands to someone who entered it from cli/.

The watch-file subtlety

cli/.envrc watches ../flake.nix and ../flake.lock explicitly. direnv's use_flake does watch_file flake.nix relative to the .envrc's own directory — i.e. exactly the two files this PR deletes. Without the explicit watches the CLI environment silently goes stale whenever the root flake changes.

Verification

Under the unified shell, from inside cli/: just build produces a working bin/traceway, and just test passes 322/322.

Behaviour change

The CLI shell no longer pins GOPATH/GOCACHE/GOBIN to cli/.go; it shares the default module cache. Keeping the isolation would have meant bare nix develop and direnv giving different shells in the same directory. An existing cli/.go is now dead weight (~205MB) and can be deletedcli/.gitignore still covers it.

Pre-existing, not touched

just check is already red on main — 19 issues (16 errcheck, 3 staticcheck). There is no .golangci.yml in cli/, so those are just the default linters firing, and no CI workflow runs the gate despite CLAUDE.md calling it the pre-commit gate. Worth its own PR: settle the lint policy, fix what survives it, then wire it into CI.

🤖 Generated with Claude Code

cli/flake.nix and the root flake declared the identical input
(github:NixOS/nixpkgs/nixos-unstable) but carried locks generated ~94
days apart, so the CLI built against go 1.26.3 and the backend against
1.26.5. Two sibling flakes cannot share a lock -- `follows` only
redirects a flake's own transitive inputs -- so the CLI's flake is
removed and cli/.envrc now points at the root flake's `cli` shell.

Nix resolves a bare `nix develop` up to the enclosing git root, so the
~60 existing `nix develop` invocations under cli/ (README, docs, plan
docs, the integration-test skill) keep working without edits. To keep
that a superset rather than a downgrade, gomodifytags and impl move into
the root shell's Go tooling.

The `cli` shell is its own derivation rather than an alias of `backend`:
they carry the same packages, but an alias would announce itself as
"backend" and print backend run commands to someone who entered it from
cli/.

cli/.envrc watches ../flake.nix and ../flake.lock explicitly: direnv's
use_flake watches ./flake.nix and ./flake.lock relative to the .envrc's
own directory, and those are exactly the two files this commit deletes,
so without the explicit watches the CLI environment would go stale
whenever the root flake changed.

Verified under the unified shell: `just build` produces bin/traceway and
`just test` passes all 322 tests.

Behaviour change: the CLI shell no longer sets GOPATH/GOCACHE/GOBIN to
cli/.go, so the CLI shares the default module cache. An existing cli/.go
is now dead weight and can be deleted; cli/.gitignore still covers it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@FrameAutomata
FrameAutomata force-pushed the chore/unify-nixpkgs-input branch from 2c46c0c to 34e89fc Compare August 25, 2026 20:15
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.

1 participant