feat(fish-deps): build fish from source via git + cargo when upgrading
Adds a git-cargo-fish install method that clones fish-shell, checks out the latest tag, and runs `uv run --no-managed-python cargo install --path .`. This is offered first in `fish-deps install` (requires cargo + uv) and used automatically by `fish-deps update`, falling back to the system PM when cargo or uv are absent. Removes the stale `cargo install fish` README note (that crate is a library, not the shell binary).
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
# _fdc_cargo — cargo crate name, or "" if not on crates.io
|
||||
# _fdc_pm — system PM package name, or "" if not in repos
|
||||
# _fdc_special — special install key: rustup-installer | fisher-bootstrap |
|
||||
# fzf-update | paru-build | pipx | curl-installer | "" (none)
|
||||
# fzf-update | paru-build | pipx | curl-installer |
|
||||
# git-cargo-fish | "" (none)
|
||||
#
|
||||
# cargo is listed second so it is installed before Rust tools that depend on it.
|
||||
function _fish_deps_catalog
|
||||
@@ -25,7 +26,7 @@ function _fish_deps_catalog
|
||||
rec rec rec rec rec rec rec rec rec rec rec rec rec rec
|
||||
|
||||
set -g _fdc_cargo \
|
||||
fish "" "" starship "" zoxide "" "" \
|
||||
"" "" "" starship "" zoxide "" "" \
|
||||
"" "" \
|
||||
eza lsd bat "" du-dust "" "" "" ripgrep "" "" trashy "" ""
|
||||
|
||||
@@ -35,7 +36,7 @@ function _fish_deps_catalog
|
||||
eza lsd bat btop dust duf prettyping most ripgrep lazygit lazydocker trash kitty wezterm
|
||||
|
||||
set -g _fdc_special \
|
||||
"" rustup-installer fisher-bootstrap curl-installer fzf-update "" "" paru-build \
|
||||
git-cargo-fish rustup-installer fisher-bootstrap curl-installer fzf-update "" "" paru-build \
|
||||
wakatime-binary "" \
|
||||
"" "" "" "" "" "" "" "" "" "" curl-lazydocker "" "" ""
|
||||
end
|
||||
|
||||
@@ -47,6 +47,18 @@ function _fish_deps_install
|
||||
|
||||
# Preferred special methods — listed before system PM so they are the default
|
||||
switch $special
|
||||
case git-cargo-fish
|
||||
if type -q cargo; and type -q uv
|
||||
set -a methods special-git-cargo-fish
|
||||
set -a method_labels "build from source (git + cargo)"
|
||||
else
|
||||
set_color brblack
|
||||
set -l _need
|
||||
type -q cargo; or set -a _need cargo
|
||||
type -q uv; or set -a _need uv
|
||||
echo " note: "(string join " and " $_need)" not found — install them first to build fish from source"
|
||||
set_color normal
|
||||
end
|
||||
case rustup-installer
|
||||
set -a methods special-rustup
|
||||
set -a method_labels "rustup installer (curl | sh)"
|
||||
@@ -194,6 +206,21 @@ function _fish_deps_install
|
||||
and makepkg -si --noconfirm
|
||||
and popd
|
||||
rm -rf $_build_dir
|
||||
case special-git-cargo-fish
|
||||
set -l _tmpdir (mktemp -d)
|
||||
set -l _build_ok 0
|
||||
git clone https://github.com/fish-shell/fish-shell "$_tmpdir"
|
||||
and begin
|
||||
set -l _tag (git -C "$_tmpdir" for-each-ref refs/tags/ --format '%(refname:short)' --sort=version:refname | tail -1)
|
||||
test -n "$_tag"; and git -C "$_tmpdir" checkout "$_tag"
|
||||
true
|
||||
end
|
||||
and pushd "$_tmpdir"
|
||||
and uv run --no-managed-python cargo install --path .
|
||||
and set _build_ok 1
|
||||
popd 2>/dev/null
|
||||
rm -rf "$_tmpdir"
|
||||
test $_build_ok -eq 1
|
||||
case special-pipx
|
||||
pipx install $bin
|
||||
case special-pip
|
||||
|
||||
@@ -93,6 +93,45 @@ function _fish_deps_update
|
||||
continue
|
||||
end
|
||||
|
||||
# fish: prefer build from source via git + cargo; fall back to PM
|
||||
if test "$special" = git-cargo-fish
|
||||
if type -q cargo; and type -q uv
|
||||
echo "Updating $bin..."
|
||||
set -l _tmpdir (mktemp -d)
|
||||
set -l _build_ok 0
|
||||
git clone https://github.com/fish-shell/fish-shell "$_tmpdir"
|
||||
and begin
|
||||
set -l _tag (git -C "$_tmpdir" for-each-ref refs/tags/ --format '%(refname:short)' --sort=version:refname | tail -1)
|
||||
test -n "$_tag"; and git -C "$_tmpdir" checkout "$_tag"
|
||||
true
|
||||
end
|
||||
and pushd "$_tmpdir"
|
||||
and uv run --no-managed-python cargo install --path .
|
||||
and set _build_ok 1
|
||||
popd 2>/dev/null
|
||||
rm -rf "$_tmpdir"
|
||||
if test $_build_ok -eq 1
|
||||
set updated_any 1
|
||||
set_color yellow
|
||||
echo " Fish updated — restart your shell to use the new version."
|
||||
set_color normal
|
||||
end
|
||||
else if test -n "$pm_pkg"; and test -n "$pm"
|
||||
echo "Updating $bin (cargo/uv unavailable, using system PM)..."
|
||||
_fish_deps_pm_upgrade $pm_pkg
|
||||
set updated_any 1
|
||||
set_color yellow
|
||||
echo " Fish updated — restart your shell to use the new version."
|
||||
set_color normal
|
||||
else
|
||||
set_color yellow
|
||||
echo " fish: cannot update — install cargo and uv to build from source"
|
||||
set_color normal
|
||||
end
|
||||
set i (math $i + 1)
|
||||
continue
|
||||
end
|
||||
|
||||
# curl-installer tools (starship etc.): re-run install script, which upgrades in place
|
||||
if test "$special" = curl-installer
|
||||
if test "$bin" = starship
|
||||
@@ -109,11 +148,6 @@ function _fish_deps_update
|
||||
echo "Updating $bin..."
|
||||
cargo install --force $cargo_crate
|
||||
set updated_any 1
|
||||
if test "$bin" = fish
|
||||
set_color yellow
|
||||
echo " Fish updated — restart your shell to use the new version."
|
||||
set_color normal
|
||||
end
|
||||
set i (math $i + 1)
|
||||
continue
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user