Skip to content

Commit

Permalink
Move more functions from install.fish to myinstall
Browse files Browse the repository at this point in the history
  • Loading branch information
JafarAbdi committed Oct 11, 2024
1 parent 277d6c6 commit 6709b12
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 147 deletions.
43 changes: 0 additions & 43 deletions Makefile

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
## Installation

```bash
make setup-fish core
make host # Host specific configs
make dev
~/myconfigs/scripts/.local/bin/myinstall setup_fish
```

- Install tailscale: [tailscale](https://tailscale.com/download)
Expand Down
73 changes: 0 additions & 73 deletions fish/conf.d/installs.fish
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
function install-from-github
if test (count $argv) -ne 2
echo "install-from-github requires 2 inputs USER/REPO regex"
return 1
end
curl -s https://api.github.com/repos/$argv[1]/releases \
| grep -E "https://github.com/$argv[1]/releases/download.*$argv[2]" \
| cut -d':' -f 2,3 \
| tr -d \" \
| head -n 1 \
| wget -i -
end
function config-fish
rm -rf ~/.config/fish || true && mkdir -p ~/.config/fish
echo "source ~/myconfigs/fish/config.fish" | tee ~/.config/fish/config.fish
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
# To be able to source bash scripts
fisher install edc/bass
# Skip setting fish as the default shell if we are in a docker or podman containers
if ! test -e /.dockerenv && test -z $PODMAN_NAME
chsh -s /usr/bin/fish
end
end
## CPP ##
function install-bloaty
git clone [email protected]:google/bloaty.git
cd bloaty
Expand Down Expand Up @@ -70,7 +44,6 @@ function install-cpp-analyzers
end

## ROS ##
function install-colcon
sudo apt install -y 'python3-colcon-*' python3-vcstool python3-rosdep
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
Expand All @@ -79,16 +52,6 @@ function install-colcon
rosdep update
end

function install-urdf-viz
sudo apt install -y rospack-tools
set -l TMP_DIR (mktemp -d -p /tmp install-XXXXXX)
cd $TMP_DIR
install-from-github openrr/urdf-viz urdf-viz-x86_64-unknown-linux-gnu.tar.gz
ex urdf-viz-x86_64-unknown-linux-gnu.tar.gz
mv urdf-viz ~/.local/bin
cd -
end
function install-ros2
if test (count $argv) -ne 1
echo "install-ros2 expects 1 argument for the distribution name"
Expand Down Expand Up @@ -124,42 +87,6 @@ function install-ros2
install-colcon
end

## Configs ##
function unstow-configs
stow --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --delete cargo \
clangd \
i3 \
git \
neovim \
ruff \
scripts \
stylua \
tmux \
fd \
ripgrep \
wezterm \
yamllint \
zathura
end
function stow-configs
stow --no-folding --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --stow cargo \
clangd \
git \
ruff \
scripts \
stylua \
fd \
ripgrep \
yamllint \
zathura
stow --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --stow i3 \
wezterm \
neovim \
tmux
end
# Profilers
function install-pyinstrument
pip3 install -U pyinstrument
Expand Down
30 changes: 5 additions & 25 deletions fish/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ function get_path
if test -d /usr/lib/ccache
set path /usr/lib/ccache:$path
end
if test -d $WORKSPACE_DIR/cling
set path $WORKSPACE_DIR/cling/bin:$path
end
if test -d $WORKSPACE_DIR/heaptrack
set path $WORKSPACE_DIR/heaptrack/install/bin:$path
end
Expand All @@ -31,28 +28,16 @@ function get_path
if test -d $WORKSPACE_DIR/easy_profiler
set path $WORKSPACE_DIR/easy_profiler/install/bin:$path
end
if test -d $WORKSPACE_DIR/vcpkg
set path $WORKSPACE_DIR/vcpkg:$path
end
if test -d /opt/drake/bin
set path /opt/drake/bin:$path
end
if test -d $HOME/.cargo/bin
export CARGO_NET_GIT_FETCH_WITH_CLI=true
set path $HOME/.cargo/bin:$path
end
if test -d $HOME/.config/mold/bin
set path $HOME/.config/mold/bin:$path
end
if test -d $HOME/.poetry/bin
set path $HOME/.poetry/bin:$path
end
if test -d $HOME/.config/lua-lsp/bin
set path $HOME/.config/lua-lsp/bin:$path
end
if test -d $HOME/.config/efm-lsp
set path $HOME/.config/efm-lsp:$path
end
if test -d $NPM_PACKAGES/bin
set path $NPM_PACKAGES/bin:$path
end
Expand All @@ -62,12 +47,6 @@ function get_path
if test -d $HOME/.config/zig
set path $HOME/.config/zig:$path
end
if test -d $HOME/.config/mosek/10.0/tools/platform/linux64x86/bin
set path $HOME/.config/mosek/10.0/tools/platform/linux64x86/bin:$path
if test -f $HOME/mosek/mosek.lic
export MOSEKLM_LICENSE_FILE=$HOME/mosek/mosek.lic
end
end
echo $path
end

Expand Down Expand Up @@ -647,8 +626,9 @@ function setup_container
docker cp $HOME/.local/share/nvim $container_name:$HOME/.local/share/nvim && \
docker exec -it $container_name bash -c "chown -R $USER:$USER $HOME/.local"
end
docker exec --user root -it $container_name bash -c "apt update && apt install make"
docker exec -it $container_name bash -c "cd ~/myconfigs && make setup-fish core dev-core dev-cpp dev-python"
docker exec --user root -it $container_name bash -c "apt update && apt install make stow -y"
docker exec -it $container_name bash -c "~/myconfigs/scripts/.local/bin/myinstall setup_fish"
docker exec -it $container_name fish -c "source ~/myconfigs/fish/conf.d/installs.fish && stow-configs"
end

complete -c setup_container -x -a '(__fish_print_docker_containers running)'
Expand Down Expand Up @@ -741,8 +721,8 @@ function start_container -d "Start a podman|docker image with gpu support"
end
eval '$containerprg exec --user root $cid bash -c "passwd -d $user"'
eval '$containerprg exec --user root $cid bash -c "chown $user:$user /home/$user"'
eval '$containerprg exec --user root $cid bash -c "chown $user:$user /home/$user/.config"'
eval '$containerprg exec --user root $cid bash -c "chown $user:$user /home/$user/.local"'
eval '$containerprg exec --user root $cid bash -c "chown -R $user:$user /home/$user/.config"'
eval '$containerprg exec --user root $cid bash -c "chown -R $user:$user /home/$user/.local"'
eval '$containerprg exec --user root $cid bash -c "chown $user:$user /run/user/$user_id"'
if test $containerprg = "podman"
# TODO: Why this's no longer working?
Expand Down
85 changes: 82 additions & 3 deletions scripts/.local/bin/myinstall
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ case "${1:-}" in
git-core \
git-lfs \
ssh \
unzip \
colordiff \
tree \
less \
Expand Down Expand Up @@ -246,11 +247,11 @@ case "${1:-}" in
if [ "$(lsb_release -sr)" = "unstable" ]; then
sudo apt install -y efm-langserver
else
mkdir -p ~/.config/efm-lsp
rm -rf ~/.config/efm-lsp/* 2> /dev/null
pushd ~/.config/efm-lsp || exit 1
TMP_DIR=$(mktemp -d -p /tmp install-XXXXXX)
pushd "$TMP_DIR" || exit 1
install_from_github mattn/efm-langserver "efm-langserver_.*_linux_amd64.tar.gz"
tar xzf efm-langserver* --strip-components 1
mv efm-langserver ~/.local/bin
popd || exit 1
fi
;;
Expand Down Expand Up @@ -490,6 +491,84 @@ case "${1:-}" in
popd || exit 1
;;

install_from_github)
if [ $# -ne 3 ]; then
error "install-from-github requires 2 inputs USER/REPO regex"
fi
install_from_github "$2" "$3"
;;

setup_fish)
if [ "$(id -u)" -eq 0 ]; then
info "Installing packages without sudo..."
apt update
apt install -y software-properties-common curl wget && apt-add-repository -y ppa:fish-shell/release-3
apt install -y fish
else
info "Installing packages with sudo..."
sudo apt update
sudo apt install -y software-properties-common curl wget && sudo apt-add-repository -y ppa:fish-shell/release-3
sudo apt install -y fish
fi

rm -rf ~/.config/fish || true
mkdir -p ~/.config/fish

echo "source ~/myconfigs/fish/config.fish" > ~/.config/fish/config.fish

# To be able to source bash scripts
fish -c "curl -sL https://git.io/fisher | source && fisher install edc/bass"

# Skip setting fish as the default shell if we are in a docker or podman containers
if [ ! -e /.dockerenv ] && [ -z "$PODMAN_NAME" ]; then
chsh -s /usr/bin/fish
fi
;;

unstow)
stow --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --delete cargo \
clangd \
i3 \
git \
neovim \
ruff \
scripts \
stylua \
tmux \
fd \
ripgrep \
wezterm \
yamllint \
zathura
;;

stow)
stow --no-folding --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --stow cargo \
clangd \
git \
ruff \
scripts \
stylua \
fd \
ripgrep \
yamllint \
zathura
stow --target ~ --ignore=.mypy_cache --ignore=.ruff_cache --stow i3 \
wezterm \
neovim \
tmux
;;

urdf_viz)
install_package rospack-tools
TMP_DIR=$(mktemp -d -p /tmp install-XXXXXX)
pushd "$TMP_DIR" || exit 1
install_from_github openrr/urdf-viz urdf-viz-x86_64-unknown-linux-gnu.tar.gz
extract urdf-viz-x86_64-unknown-linux-gnu.tar.gz
mv urdf-viz ~/.local/bin
popd || exit 1
;;

*)
info "Usage: $(basename "$0") <option>" >&2
list_options
Expand Down

0 comments on commit 6709b12

Please sign in to comment.