Skip to content
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

Only add Nix paths to $PATH if not already in there #9297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scripts/nix-profile-daemon.sh.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Only execute this file once per shell.
if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi
__ETC_PROFILE_NIX_SOURCED=1
export __ETC_PROFILE_NIX_SOURCED=1

NIX_LINK=$HOME/.nix-profile
if [ -n "${XDG_STATE_HOME-}" ]; then
Expand Down Expand Up @@ -60,5 +60,12 @@ else
unset -f check_nix_profiles
fi

export PATH="$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin:$PATH"
# only append once
case ":$PATH:" in
*:"$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin":*)
;;
*)
export PATH="$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin:$PATH"
;;
esac
unset NIX_LINK
23 changes: 21 additions & 2 deletions scripts/nix-profile.sh.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Only execute this file once per shell.
if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi
export __ETC_PROFILE_NIX_SOURCED=1

if [ -n "$HOME" ] && [ -n "$USER" ]; then

# Set up the per-user profile.
Expand Down Expand Up @@ -51,9 +55,24 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
# pick up `.nix-profile/share/man` because is it close to `.nix-profile/bin`
# which is in the $PATH. For more info, run `manpath -d`.
if [ -n "${MANPATH-}" ]; then
export MANPATH="$NIX_LINK/share/man:$MANPATH"
# only append once
case ":$MANPATH:" in
*:"$NIX_LINK/share/man":*)
;;
*)
export MANPATH="$NIX_LINK/share/man:$MANPATH"
;;
esac
fi

export PATH="$NIX_LINK/bin:$PATH"
# only append once
case ":$PATH:" in
*:"$NIX_LINK/bin":*)
;;
*)
export PATH="$NIX_LINK/bin:$PATH"
;;
esac

unset NIX_LINK NIX_LINK_NEW
fi