fix(daemon): add Nix Home Manager PATH support to service environment#59935
fix(daemon): add Nix Home Manager PATH support to service environment#59935BunsDev merged 94 commits intoopenclaw:mainfrom
Conversation
Add addNixProfileBinDirs() helper that resolves both the default ~/.nix-profile/bin path and all profile paths from the NIX_PROFILES environment variable (space-separated, used by multi-profile Nix setups). Uses appendSubdir() for consistent and defensive path handling, avoiding raw template literals that could produce double /bin paths. Called from both resolveDarwinUserBinDirs() and resolveLinuxUserBinDirs() so the fix works on all Unix platforms. Fixes openclaw#44402 Supersedes openclaw#44433
Greptile SummaryAdds Confidence Score: 5/5Safe to merge — logic is correct, well-tested, and consistent with existing patterns. The implementation correctly resolves the default ~/.nix-profile/bin and all NIX_PROFILES-listed profile paths, uses appendSubdir for the /bin suffix guard, and forwards env properly through the existing call chain. The only minor observation is that addNixProfileBinDirs can produce duplicate entries in the intermediate dirs array when NIX_PROFILES includes ~/.nix-profile, but deduplication already happens at getMinimalServicePathParts and this is the established pattern throughout the file. Six new tests cover the key scenarios. No files require special attention. Reviews (1): Last reviewed commit: "fix(daemon): add Nix Home Manager PATH s..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Adds Nix Home Manager profile bin directories into the daemon’s computed service PATH so LaunchAgent/systemd environments can locate Nix-installed binaries (addressing missing ~/.nix-profile/bin in generated service envs).
Changes:
- Introduce
addNixProfileBinDirs()to add~/.nix-profile/binandNIX_PROFILES-derived*/binentries into user PATH dir resolution. - Invoke the new helper from both macOS and Linux user-bin resolution paths.
- Add unit tests validating default and
NIX_PROFILES-based Nix PATH entries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/daemon/service-env.ts | Adds shared Nix profile PATH resolution and wires it into Darwin/Linux user PATH assembly. |
| src/daemon/service-env.test.ts | Adds tests asserting ~/.nix-profile/bin and NIX_PROFILES-derived bin dirs appear in minimal service PATH parts. |
- Narrow doc comment to 'darwin and linux' instead of 'all Unix' - Add missing single-profile macOS test (7 tests total) - Move all Nix tests into dedicated describe block for clearer grouping
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 946e82eebe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb5d6078bc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71d7e65ea0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| addNonEmptyDir(dirs, appendSubdir(profile, "bin")); | ||
| } | ||
| } else { | ||
| dirs.push(`${home}/.nix-profile/bin`); |
There was a problem hiding this comment.
Use modern Nix profile path in fallback
When NIX_PROFILES is unset, this fallback always injects ~/.nix-profile/bin, but newer Nix installs can use ${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile as the active user profile and may not keep a legacy ~/.nix-profile link. In that environment the daemon still misses Nix-managed binaries, so the bug this patch targets remains reproducible for users on the newer profile layout.
Useful? React with 👍 / 👎.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for #66884 that restated alexlomt's already-formatted entry one line above.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (openclaw#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (openclaw#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (openclaw#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for openclaw#66884 that restated alexlomt's already-formatted entry one line above.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (openclaw#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (openclaw#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (openclaw#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for openclaw#66884 that restated alexlomt's already-formatted entry one line above.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (openclaw#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (openclaw#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (openclaw#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for openclaw#66884 that restated alexlomt's already-formatted entry one line above.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (openclaw#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (openclaw#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (openclaw#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for openclaw#66884 that restated alexlomt's already-formatted entry one line above.
Three external-contributor commits from the last day landed without CHANGELOG entries: - Alex Fries (openclaw#68286, @ajfonthemove): hybrid memory search component scores. Added under Unreleased > Changes (feat). - Charles Dusek (openclaw#51267, @cgdusek): malformed tool-result text-block guard. Added under Unreleased > Fixes. - Jerome Benoit (openclaw#59935, @jerome-benoit): Nix Home Manager daemon PATH support. Added under Unreleased > Fixes. Also drop a duplicate raw-subject changelog line for openclaw#66884 that restated alexlomt's already-formatted entry one line above.
Summary
openclaw gateway installgenerates a service plist/unit that misses Nix-managed binaries from PATH. Skills depending on Nix-installed binaries (e.g.aoe,tmux,claude) are reported asblockedat boot.addNixProfileBinDirs()toservice-env.tsthat resolves Nix profile bin directories fromNIX_PROFILES(respecting right-to-left precedence) with a~/.nix-profile/binfallback when the env var is absent.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
openclaw gateway installdoes not capture Nix (Home Manager) PATH entries in LaunchAgent plist #44402Root Cause (if applicable)
getMinimalServicePathParts()had no knowledge of Nix profile directories. The LaunchAgent/systemd service PATH is constructed from a static list of known bin dirs, and Nix paths were missing entirely.~/.nix-profile/binand setsNIX_PROFILESwith a space-separated list of profile paths. The daemon service environment doesn't source shell init scripts, so these paths must be resolved explicitly.Regression Test Plan (if applicable)
src/daemon/service-env.test.tsNIX_PROFILESentry = highest priority), and fallback to~/.nix-profile/binwhenNIX_PROFILESis absent.getMinimalServicePathParts/getMinimalServicePathPartsFromEnvdirectly validate the PATH resolution without requiring a running gateway or service installation.User-visible / Behavior Changes
hasBinary()checks at boot will find Nix-managed tools without manual PATH configuration.Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
NIX_PROFILES="/nix/var/nix/profiles/default ~/.nix-profile"Steps
openclaw gateway installopenclaw channels status --probefor blocked skillsExpected
Actual
~/.nix-profile/binare missing from the service PATH.Evidence
7 new unit tests validate the added behavior: fallback (Linux/macOS), two-profile precedence (Linux/macOS), single profile (Linux/macOS), three-profile precedence ordering. No pre-existing tests existed for this code path.
Human Verification (required)
pnpm check(0 warnings, 0 errors),pnpm testscoped toservice-env.test.ts(7/7 Nix tests pass).scripts/nix-profile-daemon.sh.in).Review Conversations
4 Codex review comments about NIX_PROFILES precedence are addressed by the latest commit but not yet resolved on GitHub — pending maintainer review.
Compatibility / Migration
Risks and Mitigations
NIX_PROFILEScontains unexpected entries (e.g. non-existent paths).addNonEmptyDir+appendSubdirguard against empty/malformed paths. Non-existent directories in PATH are harmless (skipped by the OS at lookup time).Key difference from #44433
Uses
appendSubdir(profile, "bin")instead of raw template literal${profile}/bin, consistent with all other env-configured bin dirs in the file, and guards against double/binpaths.