diff options
author | Alexandre Thomas <alexandre.thomas@alice-bob.com> | 2023-01-03 21:06:47 +0100 |
---|---|---|
committer | Alexandre Thomas <alexandre.thomas@alice-bob.com> | 2023-01-03 21:14:01 +0100 |
commit | 49e058f1cfbf315e9bcb664ef884e27eb48cacb5 (patch) | |
tree | 1427c726f4fef7ccbdcc46475d505c835e338e47 /scripts/nix-profile.fish.in | |
parent | 15341334b50b2b432830a8e78abc331d0a47de13 (diff) |
Fix Nix installation on older versions of fish
The `fish_add_path` function is only available for fish 3.2.0 or newer,
and not on older versions.
This commit adds an alternative way to update the PATH when
`fish_add_path` does not exist.
Diffstat (limited to 'scripts/nix-profile.fish.in')
-rw-r--r-- | scripts/nix-profile.fish.in | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/scripts/nix-profile.fish.in b/scripts/nix-profile.fish.in index 8d783d7c0..731498c76 100644 --- a/scripts/nix-profile.fish.in +++ b/scripts/nix-profile.fish.in @@ -1,3 +1,15 @@ +function add_path --argument-names new_path + if type -q fish_add_path + # fish 3.2.0 or newer + fish_add_path --prepend --global $new_path + else + # older versions of fish + if not contains $new_path $fish_user_paths + set --global fish_user_paths $new_path $fish_user_paths + end + end +end + if test -n "$HOME" && test -n "$USER" # Set up the per-user profile. @@ -32,6 +44,8 @@ if test -n "$HOME" && test -n "$USER" set --export --prepend --path MANPATH "$NIX_LINK/share/man" end - fish_add_path --prepend --global "$NIX_LINK/bin" + add_path "$NIX_LINK/bin" set --erase NIX_LINK end + +functions -e add_path |