Skip to content

fix(platform): surface Nix-managed agent CLI install paths - #6334

Open
xxiaoxiong wants to merge 1 commit into
nexu-io:mainfrom
xxiaoxiong:fix/6121-nix-cli-discovery
Open

fix(platform): surface Nix-managed agent CLI install paths#6334
xxiaoxiong wants to merge 1 commit into
nexu-io:mainfrom
xxiaoxiong:fix/6121-nix-cli-discovery

Conversation

@xxiaoxiong

Copy link
Copy Markdown
Contributor

What this PR does

Before this PR:
The packaged macOS (and Linux) Desktop app did not discover agent CLIs installed through nix-darwin environment.systemPackages or per-user nix profile install. After launching the app normally from Finder/Applications and rescanning Local CLI agents, Codex, Claude Code, and Gemini were reported as not found on PATH, even though command -v codex / claude / gemini resolved cleanly from a terminal.

After this PR:
Those same Nix-installed CLIs are detected after the next rescan. No user action beyond the standard rescan flow is required.

Why we need it & why it was done this way

#6121 reports the bug. The root cause is architectural, not a typo: in a GUI-launched Electron process the inherited PATH is minimal (launchd does not source the user's shell rc), so CLI discovery relies on wellKnownUserToolchainBins in packages/platform/src/toolchain.ts to surmise the canonical install locations for every popular package manager.

That helper already covered Homebrew, npm/nvm/fnm/mise/asdf, Deno, Go, pyenv, Scoop, Volta, Vite+, Kimi, Bun, Cargo and the system Homebrew locations — but did not include the standard Nix install roots. Per the Nix manual, the canonical locations for user-installed / system-installed CLIs are:

  • /run/current-system/sw/bin — system profile on NixOS / nix-darwin. environment.systemPackages entries land here.
  • ~/.nix-profile/bin — per-user Nix profile. nix profile install entries land here.

The fix reuses the existing two-tier structure of wellKnownUserToolchainBins:

  • ~/.nix-profile/bin joins the user-level list (alongside ~/.deno/bin, ~/go/bin, ~/.pyenv/shims). It is includeSystemBins-independent, mirroring how those sibling user-managed toolchain dirs are surfaced unconditionally.
  • /run/current-system/sw/bin joins the includeSystemBins-gated block, next to /opt/homebrew/bin and /usr/local/bin, because it is a system-installed-binaries location. Same includeSystemBins semantics: still emitted in the default process.platform !== "win32" path, still configurable via the includeSystemBins opt-in flag.

This matches packages/AGENTS.md: platform's toolchain helper is the single source of truth shared by the daemon agent resolver (apps/daemon/src/agents.ts) and the packaged sidecar PATH builder (apps/packaged/src/sidecars.ts). Both consumers automatically pick up the new entries; neither needs its own change.

Tradeoffs

  • /nix/var/nix/profiles/default/bin is omitted. This is the system-default profile on multi-user NixOS installs. The reported bug ([Bug]: Desktop app does not discover agent CLIs installed through Nix #6121) only references /run/current-system/sw/bin and ~/.nix-profile/bin, so I kept the diff to the two paths the issue named and that the Nix manual documents as the canonical user/system profile roots. Adding /nix/var/nix/profiles/default/bin is a one-line follow-up if a maintainer wants the explicit full set; the existing list is already a pragmatic subset of well-known locations, not an exhaustive enumeration.
  • I did not move /run/current-system/sw/bin ahead of /opt/homebrew/bin. Existing precedence ordering in the system block (homebrew wins for the macOS "first via Homebrew" convention) is preserved; Nix users who also have Homebrew-installed CLIs with the same name will keep seeing the Homebrew shim. A different ordering is a behavior change beyond this issue's scope.
  • ~/.nix-profile/bin is added to the user-level CLI list (includeSystemBins: false path), not gated. This is intentional and matches siblings (~/.deno/bin, ~/go/bin, ~/.pyenv/shims) — Nix users should not have to flip a system-bins flag to have their user-installed Nix CLIs discovered.

Breaking changes

None. Additive only — two new entries in the well-known list. Existing entries and ordering unchanged. wellKnownUserToolchainBins returns the same set of paths for all existing inputs, plus the new entries when they exist on disk (best-effort, missing dirs contribute nothing).

How to verify

pnpm --filter @open-design/platform typecheck
pnpm --filter @open-design/platform test

Both pass on this branch. The two existing wellKnownUserToolchainBins tests have been extended by one assertion each (the Deno, Go, pyenv test now also asserts ~/.nix-profile/bin; the includeSystemBins true/false tests now also assert /run/current-system/sw/bin). No new test cases were added to avoid duplication — the two existing tests already cover the code paths being changed.

On a NixOS / nix-darwin machine, install any agent CLI through environment.systemPackages or nix profile install, launch the packaged Desktop app from Finder/Applications, then Settings → Local CLI agents → Rescan. The previously-missing CLI now appears.

Fixes #6121

The packaged macOS (and Linux) Desktop app did not discover agent
CLIs installed through nix-darwin `environment.systemPackages` or
per-user `nix profile install`. After launching from Finder and
rescanning, Codex / Claude Code / Gemini resolved cleanly from a
terminal but were reported as not found on `PATH`.

Root cause: in a GUI-launched Electron process the inherited `PATH`
is minimal (launchd does not source the user's shell rc), so
discovery relies on `wellKnownUserToolchainBins` in
`packages/platform/src/toolchain.ts`. The helper's well-known
list covered Homebrew, npm/nvm/fnm/mise/asdf, Deno, Go, pyenv,
Scoop, Volta, Vite+, Kimi, Bun, Cargo and the system Homebrew
locations, but did not include the standard Nix install roots:

- `/run/current-system/sw/bin` (NixOS / nix-darwin system profile)
- `~/.nix-profile/bin` (per-user Nix profile)

Both are documented well-known paths in Nix documentation and are
the canonical locations CLIs installed via `environment.systemPackages`
or `nix profile install` end up in.

Changes:

- `packages/platform/src/toolchain.ts`:
  - Add `~/.nix-profile/bin` to the user-level CLI install list
    (alongside Deno / Go / pyenv) so single-user Nix installs are
    surfaced the same way Homebrew/etc are. Best-effort — a missing
    dir contributes nothing; the existing `<dir>/bin` join behaviour
    is preserved.
  - Add `/run/current-system/sw/bin` to the
    `includeSystemBins`-gated block, next to `/opt/homebrew/bin`
    and `/usr/local/bin`. Same rationale: a NixOS / nix-darwin
    system-installed CLI lives here, and a GUI-launched daemon
    needs the explicit probe to find it.

- `packages/platform/tests/index.test.ts`:
  - Extend the existing "Deno, Go, pyenv" user-level test to also
    assert `~/.nix-profile/bin` is returned.
  - Extend both `includeSystemBins` true/false tests to also
    assert `/run/current-system/sw/bin` is included / omitted
    accordingly. Two assertions in two existing tests, no new
    test cases to keep the file dense.

Verified: `pnpm --filter @open-design/platform test` passes 76/76
tests, `pnpm --filter @open-design/platform typecheck` clean.

Fixes nexu-io#6121

Signed-off-by: xxiaoxiong <2482929840@qq.com>
@xxiaoxiong
xxiaoxiong requested a review from a team as a code owner August 2, 2026 10:09
@lefarcen

lefarcen commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Hey @xxiaoxiong — thanks for tracing this back to the shared toolchain resolver and keeping the fix scoped to the two Nix install roots called out in #6121. I’ve queued the normal triage on our side so this can move through review cleanly.

@lefarcen
lefarcen requested a review from PerishCode August 2, 2026 10:13
@lefarcen lefarcen added size/S PR changes 20-100 lines risk/medium Medium risk: regular code changes type/bugfix Bug fix labels Aug 2, 2026
@lefarcen

lefarcen commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the detailed Nix-path analysis — the root-cause write-up makes the scope easy to follow. Could you remap that content into the current PR template with explicit Why, What users will see, Surface area, and Validation sections? Most of the substance is already here, so this should mostly be a quick reshape plus the relevant surface-area checkbox.

@lefarcen lefarcen added the needs-validation Runtime change detected; needs human or /explore agent validation. label Aug 2, 2026
@lefarcen

lefarcen commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🧪 Queued for QA validation — this PR has changes that need a manual QA pass before it's merged. Nothing needed from you; we'll update here once it's validated. Thanks for the contribution! 🙏

@PerishCode PerishCode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xxiaoxiong This cleanly extends the shared platform toolchain resolver with the two Nix profile locations while preserving the existing user/system gating and precedence. I verified both changed ranges and their consumers, and ran the platform tests (76/76), platform typecheck, repository guard, and full workspace typecheck successfully. Thanks for the focused fix and the careful regression coverage.

🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

@lefarcen

lefarcen commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Heads-up: PR #6125 from @Pape45 is also open against the same fix path — both PRs change packages/platform/src/toolchain.ts and packages/platform/tests/index.test.ts to add the Nix profile discovery paths for #6121.

Sharing this so the maintainer team can choose one canonical PR and neither thread ends up doing duplicate work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-validation Runtime change detected; needs human or /explore agent validation. risk/medium Medium risk: regular code changes size/S PR changes 20-100 lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Desktop app does not discover agent CLIs installed through Nix

3 participants