Skip to content

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

Merged
Mic92 merged 2 commits intoNixOS:masterfrom
stefanboca:sb/push-lmnqpuztqxmz
May 25, 2025
Merged

nix-profile{,-daemon}.fish: fix do not source twice#13244
Mic92 merged 2 commits intoNixOS:masterfrom
stefanboca:sb/push-lmnqpuztqxmz

Conversation

@stefanboca
Copy link
Contributor

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
@Mic92 Mic92 enabled auto-merge May 25, 2025 15:16
@Mic92 Mic92 merged commit 543cee1 into NixOS:master May 25, 2025
12 checks passed
@roberth roberth added backport 2.28-maintenance Automatically creates a PR against the branch backport 2.29-maintenance Automatically creates a PR against the branch backports created Does not require attention and can be filtered away labels Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
…3244

nix-profile{,-daemon}.fish: fix do not source twice (backport #13244)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.28-maintenance Automatically creates a PR against the branch backport 2.29-maintenance Automatically creates a PR against the branch backports created Does not require attention and can be filtered away

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants