Skip to content

nix-profile{,-daemon}.fish: fix do not source twice #13244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stefanboca
Copy link

Motivation

I was running into an issue with nix develop -c fish where binaries in my profile were overriding binaries from my dev shell. This because the nix-profile.fish scripts were sourced again in the child shell, which prepended the nix profile to PATH.

This PR exports __ETC_PROFILE_NIX_SOURCED from the fish profile scripts to prevent the scripts from running in child shells. This matches the bash profile scripts behavior.

Context

Commit b36637c set __ETC_PROFILE_NIX_SOURCED globally, but this is not enough to prevent the script from being run again by child shells, because the variable was not exported and thus not inherited by any child process.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Commit b36637c set
`__ETC_PROFILE_NIX_SOURCED` globally, but this is not enough to prevent
the script from being run again by child shells, because the
variable was not exported and thus not inherited by any child process.
Exporting the variable also agrees with the bash scripts.

Notably, the old behavior broke `nix develop -c fish` in some cases,
because the profile bin directory got prepended to the path, causing
binaries from the profile to override binareis from the devshell.
@stefanboca stefanboca requested a review from edolstra as a code owner May 21, 2025 18:32
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.

2 participants