feat: macos and brew install support

This commit is contained in:
Andrejus Kostarevas
2024-01-25 00:27:04 +00:00
parent 62e6c0243e
commit 61fb58e90c
15 changed files with 148 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
# Load .profile, containing login, non-bash related initializations. # Load .profile, containing login, non-bash related initializations.
[ -f "$HOME/.profile" ] && source "$HOME/.profile" [ -f "$HOME/.profile" ] && source "$HOME/.profile"
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

0
files/home/.zshrc Normal file
View File

View File

@@ -31,10 +31,6 @@ function apt_installed {
dpkg --status $1 >/dev/null dpkg --status $1 >/dev/null
} }
function clean {
sudo apt-get clean -qq
}
function update { function update {
sudo apt-get update -qq sudo apt-get update -qq
} }

View File

@@ -9,4 +9,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
sw_vers sw_vers
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
lsb_release -a lsb_release -a
else
echo "Unknown OS: $OSTYPE"
fi fi

19
script/install.d/02-brew.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# (macOS only) Install homebrew.
#
if [[ "$OSTYPE" == "darwin"* ]]; then
export NONINTERACTIVE=1
if ! bin_in_path brew; then
download_run https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh /bin/bash
else
brew update
fi
brew --version
unset NONINTERACTIVE
fi

View File

@@ -1,7 +0,0 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Install zsh shell.

20
script/install.d/03-nerdfont.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# (macOS only) Install nerdfonts.
#
if [[ "$OSTYPE" == "darwin"* ]]; then
fonts_list=(
font-fira-mono-nerd-font
font-fira-code-nerd-font
)
brew tap homebrew/cask-fonts
for font in "${fonts_list[@]}"; do
brew install --cask "$font"
done
unset fonts_list
fi

14
script/install.d/04-zsh.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Configure zsh shell.
#
if ! bin_in_path zsh; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
install zsh
fi
fi
zsh --version

View File

@@ -1,5 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Configure pyenv.
#
if ! bin_in_path "pyenv"; then if ! bin_in_path "pyenv"; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# see https://github.com/pyenv/pyenv/wiki/common-build-problems # see https://github.com/pyenv/pyenv/wiki/common-build-problems
pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist" pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist"
install_file "$pyenv_list_file" install_file "$pyenv_list_file"
@@ -8,14 +15,22 @@ if ! bin_in_path "pyenv"; then
download_run \ download_run \
"https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \ "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \
bash bash
e
unset pyenv_list_file
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install pyenv
brew install pyenv-virtualenv
fi
fi fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
virtualenv_path="$(pyenv root)/plugins/pyenv-virtualenv" virtualenv_path="$(pyenv root)/plugins/pyenv-virtualenv"
if [ ! -d "$virtualenv_path" ]; then if [ ! -d "$virtualenv_path" ]; then
git clone \ git clone \
https://github.com/pyenv/pyenv-virtualenv.git \ https://github.com/pyenv/pyenv-virtualenv.git \
$virtualenv_path $virtualenv_path
fi fi
fi
eval "$(pyenv init --path)" eval "$(pyenv init --path)"

View File

@@ -1,4 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Configure Python.
#
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
if ! bin_in_path "pip3"; then if ! bin_in_path "pip3"; then

View File

@@ -1,22 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
nvm_version="v0.38.0"
# -----------------------------------------------------------------------------
# Description:
# Configure Node.js.
#
nvm_version="0.39.7"
if ! bin_in_path "nvm"; then if ! bin_in_path "nvm"; then
download_run "https://raw.githubusercontent.com/nvm-sh/nvm/${nvm_version}/install.sh" \ download_run "https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh" \
"bash" "bash"
fi fi
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
nvm --version nvm --version
nvm alias default lts/fermium nvm alias default lts/iron
nvm install lts/fermium nvm install lts/iron
nvm use lts/fermium nvm use lts/iron
node --version node --version
yarn --version yarn --version
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
for dep in $(jq -r ".node_dependencies[]" $CONFIG); do for dep in $(jq -r ".node_dependencies[]" $CONFIG); do
yarn global add $dep yarn global add $dep
yarn global upgrade $dep yarn global upgrade $dep
done done
fi
unset nvm_version

View File

@@ -1,4 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# (Ubuntu only) Configure docker.
#
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
docker --version docker --version
readonly docker_group="docker" readonly docker_group="docker"
@@ -11,3 +18,6 @@ if ! groups "$USER" | grep -q "\b$docker_group\b"; then
echo "Adding user to docker group" echo "Adding user to docker group"
sudo usermod -aG docker "$USER" sudo usermod -aG docker "$USER"
fi fi
unset docker_group
fi

View File

@@ -1,2 +0,0 @@
#!/usr/bin/env bash
clean

13
script/install.d/98-clean.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Clean up after installation.
#
if [[ "$OSTYPE" == "darwin"* ]]; then
brew cleanup
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get autoremove -qq
sudo apt-get clean -qq
fi

View File

@@ -1,2 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# Print system information.
#
screenfetch screenfetch