fix(nix): Resolve PATH mismatch for packages option in multi-user mode#1691
Open
V-Subhankar-infy wants to merge 2 commits into
Open
fix(nix): Resolve PATH mismatch for packages option in multi-user mode#1691V-Subhankar-infy wants to merge 2 commits into
V-Subhankar-infy wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Nix feature’s multi-user installation flow so that configured packages (and optionally flakes) are installed into the default system profile that’s on users’ PATH, addressing PATH/profile mismatches in multi-user mode.
Changes:
- Install packages via
nix-envand flakes vianix profileinto a configurable target profile (used for multi-user default profile). - In multi-user mode, run post-install steps against
/nix/var/nix/profiles/defaultto align installs with the profile on PATH. - Extend Nix feature tests to assert the default profile contains expected packages.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/nix/scenarios.json | Updates the attribute-path packages scenario to use nodejs (to be prefixed to nixpkgs.nodejs). |
| test/nix/packages.sh | Adds a test assertion that vim is present in the default Nix profile. |
| src/nix/post-install-steps.sh | Adds support for installing packages/flakes into a specified Nix profile (via -p/--profile). |
| src/nix/install.sh | Switches multi-user post-install execution to target /nix/var/nix/profiles/default directly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
V-Subhankar-infy
marked this pull request as ready for review
July 23, 2026 09:36
V-Subhankar-infy
force-pushed
the
patch-nix
branch
from
July 24, 2026 13:17
72640c3 to
69ea159
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.
fix(nix): Resolve PATH mismatch and attribute-path error for packages in multi-user mode
Issues Fixed
Issue 1 — Packages installed to wrong profile in multi-user mode { Reported As Issue on Feb-16-2026 at #1573 }
Problem: In multi-user Nix installs, packages specified via the
packagesoption were silently installed into the calling user's~/.nix-profile(inside asusubshell) instead of/nix/var/nix/profiles/default— the global profile that is onPATHat runtime.Reproduction:
Root Cause:
install.shranpost-install-steps.shinsidesu ${USERNAME} -c "...". Inside that subshell,nix-envdefaulted to~/.nix-profile. Since only/nix/var/nix/profiles/default/binis onPATHat runtime, the installs were unreachable.Fix:
src/nix/install.sh— Removed thesusubshell in the multi-user branch.nix-daemon.shis sourced in the root context andNIX_FEATURE_INSTALL_PROFILE=/nix/var/nix/profiles/defaultis passed as a prefixed env var topost-install-steps.sh.src/nix/post-install-steps.sh— WhenNIX_FEATURE_INSTALL_PROFILEis set, constructs-p/--profilearg arrays and forwards them to everynix-envandnix profile installinvocation. Single-user mode is unaffected (arrays remain empty).Issue 2 — Wrong attribute path for
nodejsin packages scenarioProblem: The
packagestest scenario inscenarios.jsonusednodePackages.nodejswithuseAttributePath: true. The correct nixpkgs attribute path is simplynodejs; thenodePackages.prefix resolves a different attribute set and caused the scenario to fail at build time.Reproduction:
Fix:
test/nix/scenarios.json— CorrectednodePackages.nodejs→nodejsin thepackagesstring for theuseAttributePathscenario.Tests
check "vim_in_default_profile"totest/nix/packages.sh— runsnix-env -p /nix/var/nix/profiles/default -q | grep '^vim'to directly assert packages land in the global profile.vim_installed/node_installed/yarn_installedchecks confirm end-to-endPATHvisibility at runtime.scenarios.jsonensures theuseAttributePath+packagesscenario no longer fails on attribute resolution before the profile bug is even exercised.Impact
packagesnow correctly expose installed packages onPATH.useAttributePathpackages CI scenario is unblocked and runs cleanly.