Skip to content

Commit

Permalink
Only add Nix paths to $PATH if not already in there
Browse files Browse the repository at this point in the history
This fixes the paths being added multiple times if the user logs out and back in.
  • Loading branch information
kra-mo authored Nov 5, 2023
1 parent 8e222fb commit 92110c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion scripts/nix-profile-daemon.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@ else
unset -f check_nix_profiles
fi

export PATH="$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin:$PATH"
if ! [[ "$PATH" =~ "$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin:" ]]; then
export PATH="$NIX_LINK/bin:@localstatedir@/nix/profiles/default/bin:$PATH"
fi

unset NIX_LINK
5 changes: 4 additions & 1 deletion scripts/nix-profile.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
export MANPATH="$NIX_LINK/share/man:$MANPATH"
fi

export PATH="$NIX_LINK/bin:$PATH"
if ! [[ "$PATH" =~ "$NIX_LINK/bin:" ]]; then
export PATH="$NIX_LINK/bin:$PATH"
fi

unset NIX_LINK NIX_LINK_NEW
fi

0 comments on commit 92110c2

Please sign in to comment.