dotfiles/.config/yadm/bootstrap

95 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env zsh
cd $HOME
# Initialize and update submodules
yadm submodule update --init --recursive
yadm submodule foreach git checkout master
yadm submodule foreach git pull
# Load OS information from /etc/os-release
eval $(awk '{print "OS_" $0}' /etc/os-release)
# Install packages based on OS
if [[ ${OS_ID} == "arch" ]]; then
aur_helper="paru"
# Some pacakges are AUR packages, so we need an AUR helper.
if ! which $aur_helper &>/dev/null; then
echo "$aur_helper not found. Installing $aur_helper..."
cd /tmp/
git clone https://aur.archlinux.org/${aur_helper}-bin
cd ${aur_helper}-bin
makepkg -si --noconfirm
cd $HOME
fi
read -q "REPLY?Would you like to update the system? [Y/n] " && echo && ${aur_helper} -Syu --noconfirm
${aur_helper} -S --noconfirm --needed - <$HOME/.config/packages/arch.txt
elif [[ ${OS_ID} == "ubuntu" ]]; then
sudo apt update
sudo apt install -y $(cat $HOME/.config/packages/ubuntu.txt)
fi
function pyenv_configure() {
if [[ ${OS_ID} == "ubuntu" ]]; then
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils \
tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
curl https://pyenv.run | bash
# Add pyenv to current shell
export PATH="$HOME/.pyenv/bin:$PATH"
elif ! [[ ${OS_ID} == "arch" ]]; then
echo "Unsupported OS for automated pyenv configuration: ${OS_PRETTY_NAME}"
return 1
fi
pyenv install 3.10.13
pyenv virtualenv 3.10.13 personal
pyenv virtualenv 3.10.13 eww-modules
pyenv global personal
pyenv rehash
eval "$(pyenv init -)"
# Install packages for personal python environment
pyenv shell personal
pip install --upgrade pip
if [[ -f $HOME/.config/pip/requirements.txt ]]; then
pip install -r $HOME/.config/pip/requirements.txt
fi
# Install packages for eww-modules
pyenv shell eww-modules
pip install --upgrade pip
if [[ -f $HOME/.config/pip/eww-modules-requirements.txt ]]; then
pip install -r $HOME/.config/pip/eww-modules-requirements.txt
fi
}
# Install pyenv and configure personal and eww-modules python environments
if [[ ! -d $HOME/.pyenv ]]; then
pyenv_configure
fi
# Git configuration
config_fields=(user.name commit.gpgsign init.defaultBranch pull.rebase checkout.defaultRemote log.date log.showSignature)
config_values=(
"Ezri Brimhall"
true
main
false
origin
human
true
)
# Git is installed, yadm depends on git, so if this script is running, git is installed
if ! git config --global --get user.email &>/dev/null; then
echo "Which email address should this machine use for git?"
read "email?> "
git config --global user.email $email
fi
for i in {1..${#config_fields}}; do
if ! git config --global --get ${config_fields[$i]} &>/dev/null; then
git config --global ${config_fields[$i]} ${config_values[$i]}
fi
done