1
0
forked from extern/nix-config

Add common and bootstrap scripts

This commit adds a post-install bootstrap script meant to be run on a
user's local account in order to install packages, configure dotfiles,
and perform other setup tasks.

It may be ideal to use one universal bootstrap script instead of two
unique ones since both share many similar characteristics.
This commit is contained in:
Donovan Glover 2018-09-21 13:33:11 -04:00
parent 4e7ba005a8
commit 8fbd379917
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
3 changed files with 161 additions and 0 deletions

51
scripts/006-common Normal file
View File

@ -0,0 +1,51 @@
#!/bin/sh
#
# Common commands used to configure installed software.
set -xe
# Configure yarn
if hash yarn 2>/dev/null; then
echo 'Found yarn. Configuring it...'
yarn config set prefix /usr/local
yarn config set -- --emoji true
fi
# Set up a rust toolchain
if hash rustup 2>/dev/null; then
echo 'Found rust. Configuring the default toolchain...'
rustup install stable
rustup default stable
fi
# Start and enable docker
if hash docker 2>/dev/null; then
echo 'Found docker. Requesting administrative rights to configure the service...'
sudo systemctl start docker.service
sudo systemctl enable docker.service
fi
# Install vim plugins and make the undo directory
if hash vim 2>/dev/null; then
echo 'Found vim. Making directory for global undo and installing plugins...'
mkdir -p ~/.vim/undo
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# TODO: Prompt for confirmation before running this script
vim +PlugInstall +qall
fi
# https://github.com/masterkorp/openvpn-update-resolv-conf
# Note that openresolv should already be installed by netctl.
if hash openvpn 2>/dev/null; then
echo 'Found openvpn. Downloading open-resolv-conf.sh...'
sudo curl -fLo /etc/openvpn/update-resolv-conf.sh --create-dirs \
https://raw.githubusercontent.com/masterkorp/openvpn-update-resolv-conf/master/update-resolv-conf.sh
# TODO: Prompt for confirmation that the script is valid
fi
# Add user dirs if they don't exist yet (Desktop, Downloads, etc.)
if hash xdg-user-dirs-update 2>/dev/null; then
echo 'Found xdg-user-dirs. Attempting to create directories...'
xdg-user-dirs-update
fi

View File

@ -0,0 +1,62 @@
#!/bin/sh
set -xe
# Change the working directory to the location of this script
# Then, move up to the root directory of the git repo
cd "$(dirname "$0")"
cd ../..
# Raise an error if no environment is given
if [ "$#" -ne 1 ]; then
echo 'Usage: sh ./path/to/bootstrap <environment>'
exit 1
fi
# Install common packages if tig isn't found (one of the common packages)
if ! hash tig 2>/dev/null; then
echo 'Installing common packages...'
sudo pacman -Syu --needed - < ./packages/arch/common
echo 'Stowing common dotfiles...'
stow -S common --dir=dots --target=$HOME --no-folding --verbose=2
echo 'Configuring common packages...'
sh ./scripts/006-common
fi
# Install yay if it isn't found (needed for AUR and bspwm)
if ! hash yay 2>/dev/null; then
echo 'Installing yay...'
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si
cd ..
rm -r yay-bin
fi
# Install plasma
if [ $1 == "plasma" ]; then
echo 'Installing plasma packages...'
sudo pacman -Syu --needed --ignore discover - < ./packages/arch/plasma
exit 0
fi
# Install bspwm
if [ $1 == "bspwm" ]; then
echo 'Installing bspwm packages...'
sudo pacman -Syu --needed - < ./packages/arch/bspwm
echo 'Installing bspwm packages from AUR...'
yay -S polybar rtv shotgun launch-cmd
echo 'Stowing bspwm dotfiles...'
stow -S bspwm --dir=dots --target=$HOME --no-folding --verbose=2
exit 0
fi
# Throw an error if the script couldn't find a valid environment to use
echo 'Invalid environment specified. Must be either "plasma" or "bspwm"'
exit 1

View File

@ -0,0 +1,48 @@
#!/bin/sh
set -xe
# Change the working directory to the location of this script
# Then, move up to the root directory of the git repo
cd "$(dirname "$0")"
cd ../..
# Raise an error if no environment is given
if [ "$#" -ne 1 ]; then
echo 'Usage: sh ./path/to/bootstrap <environment>'
exit 1
fi
# Install common packages if tig isn't found (one of the common packages)
if ! hash tig 2>/dev/null; then
echo 'Installing common packages...'
sudo dnf install $(cat ./packages/fedora/common) --assumeyes
echo 'Stowing common dotfiles...'
stow -S common --dir=dots --target=$HOME --no-folding --verbose=2
echo 'Configuring common packages...'
sh ./scripts/006-common
fi
# Install gnome packages
if [ $1 == "gnome" ]; then
echo 'Installing gnome packages...'
sudo dnf install $(cat ./packages/fedora/gnome) --assumeyes
echo 'Now that the gnome packages are installed, you must set it up manually.'
exit 0
fi
# Install xfce packages
if [ $1 == "xfce" ]; then
echo 'Installing xfce packages...'
sudo dnf install $(cat ./packages/fedora/xfce) --assumeyes
echo 'Now that the xfce packages are installed, you must set it up manually.'
exit 0
fi
# Throw an error if the script couldn't find a valid environment to use
echo 'Invalid environment specified. Must be either "gnome" or "xfce"'
exit 1