Repository navigation
targets/generic-linux: restore the Nix environment in child shells - #9925
Open
khaneliman wants to merge 1 commit into
Open
khaneliman wants to merge 1 commit into
khaneliman wants to merge 1 commit into
Conversation
This was referenced Sep 11, 2026
khaneliman
force-pushed
the
session-vars-10-nix-environment
branch
from
September 11, 2026 03:12
6a79140 to
55d6576
Compare
khaneliman
force-pushed
the
session-vars-10-nix-environment
branch
2 times, most recently
from
September 30, 2026 18:58
366b22d to
ca9caf9
Compare
khaneliman
force-pushed
the
session-vars-10-nix-environment
branch
from
October 1, 2026 02:11
ca9caf9 to
632a032
Compare
ConorWilliams
added a commit
to ConorWilliams/nix
that referenced
this pull request
Nov 8, 2026
Waiting on nix-community/home-manager#9925 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On generic Linux, Home Manager sourced nix.sh through the guarded session variables file and again from Bash initExtra. nix.sh is not idempotent, so every interactive Bash startup added duplicate PATH and XDG_DATA_DIRS entries. Removing the direct call alone is not enough: a login environment can strip the values nix.sh set while keeping the exported session guard, and child shells then start without the Nix profile on PATH, without NIX_PROFILES, and without a certificate file. Generic Linux now owns a repeatable initializer for the standard Nix environment, in POSIX and native Fish, and sources it instead of nix.sh. It fills PATH, XDG_DATA_DIRS, a nonempty MANPATH, and a missing NIX_PROFILES or NIX_SSL_CERT_FILE. Entries already present keep their positions. Explicit scalar values, including empty strings, are kept. Zsh applies the same initializer in its unchanged-token branch, with scalar fallbacks that preserve home and Zsh declaration precedence. Profile selection follows the package: Nix 2.25 and later honor NIX_STATE_HOME; older Nix and Lix keep legacy or existing XDG selection. Custom profile scripts shipped in a nix.package are no longer executed, so their additional side effects are not reproduced. The news entry states that change. Tests run the generated Bash, Zsh, and Fish startup files with an inherited guard and stripped values, check repeated application, explicit empty and custom scalars, PATH precedence, and real Lix metadata selection.
khaneliman
force-pushed
the
session-vars-10-nix-environment
branch
from
November 18, 2026 01:13
632a032 to
f1cd942
Compare
This branch has not been deployed
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.
Description
On generic Linux, Home Manager sources
nix.shthrough the guarded session variables file and again from BashinitExtra.nix.shis not idempotent, so every interactive Bash startup adds duplicatePATHandXDG_DATA_DIRSentries. Removing the direct call alone is not enough: a login environment can strip the valuesnix.shset while keeping the exported session guard, and child shells then start without the Nix profile onPATH, withoutNIX_PROFILES, and without a certificate file.Generic Linux now owns a repeatable initializer for the standard Nix environment, in POSIX and native Fish, and sources it instead of
nix.sh. It fillsPATH,XDG_DATA_DIRS, a nonemptyMANPATH, and a missingNIX_PROFILESorNIX_SSL_CERT_FILE. Entries already present keep their positions. Explicit scalar values, including empty strings, are kept. Zsh applies the same initializer in its unchanged-token branch, with scalar fallbacks that preserve the precedence ofhome.sessionVariablesandprograms.zsh.sessionVariablesdeclarations.Profile selection follows the package: Nix 2.25 and later honor
NIX_STATE_HOME; older Nix and Lix keep legacy or existing XDG selection.Stated compatibility change: custom profile scripts shipped in a
nix.packageare no longer executed, so their additional side effects are not reproduced. The news entry says so.Tests run the generated Bash, Zsh, and Fish startup files with an inherited guard and stripped values. They cover repeated application, explicit empty and custom scalars, existing
PATHprecedence, home and Zsh scalar declarations, and profile selection against real Lix package metadata. Startup was also checked against Debian's real login files as an unprivileged user in a container, and against actual Nix 2.34.8 and Lix 2.95.2 packages across legacy, XDG, andNIX_STATE_HOMElayouts.Top of the session-variable stack. Part of splitting #9735 into independently reviewable changes; the stack as a whole supersedes that PR.
Checklist
nix.packageprofile scripts; news entry included.)nix fmt.nix build .#test-all.{component}: {description}format.