Skip to content

Instantly share code, notes, and snippets.

@paulbdavis
Created January 30, 2020 21:17
Show Gist options
  • Save paulbdavis/70509cdb1b429a37a219b0309414bb22 to your computer and use it in GitHub Desktop.
Save paulbdavis/70509cdb1b429a37a219b0309414bb22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
export script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
# set failure stuff
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'
set -uo pipefail
trap "$trap_msg" ERR
# allow cleanup on failure and finish
exit_cmd=""
defer() { exit_cmd="$@; $exit_cmd"; }
trap 'bash -c "$exit_cmd"' EXIT
# silently run a command, for checks
silent() { $@ >/dev/null 2>&1; }
function ensure-deps () {
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'
set -uo pipefail
trap "$trap_msg" ERR
sudo pacman -Syu base-devel sbcl
}
function ensure-quicklisp () {
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'
set -uo pipefail
trap "$trap_msg" ERR
mkdir -p "${cache_dir}/quicklisp"
quicklisp_file="${cache_dir}/quicklisp/quicklisp.lisp"
quicklisp_install_path="${data_dir}/quicklisp"
if [[ -d "${quicklisp_install_path}" ]]
then
echo "Found quicklisp"
return
fi
echo "Installing quicklisp"
curl https://beta.quicklisp.org/quicklisp.lisp > "${quicklisp_file}"
sbcl --load "${quicklisp_file}" \
--eval "(quicklisp-quickstart:install :path \"${quicklisp_install_path}\")" \
--eval "(quit)"
sbcl --load "${quicklisp_install_path}/setup.lisp" \
--eval '(ql:add-to-init-file)' \
--eval "(quit)"
}
function ensure-stumpwm () {
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'
set -uo pipefail
trap "$trap_msg" ERR
if [[ -x "${conf_dir}/stumpwm/.stumpwm/stumpwm" ]]
then
echo "Found stumpwm"
return
fi
echo "Installing stumpwm"
sbcl --eval "(ql:quickload '(:clx :cl-ppcre :alexandria))" \
--eval "(quit)"
lpwd=$(pwd)
cd "${script_dir}/.stumpwm"
autoconf
./configure
make
cd "${lpwd}"
}
function link-files () {
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'
set -uo pipefail
trap "$trap_msg" ERR
cd "$HOME"
for file in ${script_dir}/dotfiles/*
do
dotname=".$(basename "${file}")"
echo "Linking ${file} -> $(pwd)/${dotname}"
rm -rf "${dotname}"
ln -srf "${file}" "${dotname}"
done
cd "${conf_dir}"
for file in ${script_dir}/xdg-conf/*
do
confname="$(basename "${file}")"
echo "Linking ${file} -> $(pwd)/${confname}"
rm -rf "${confname}"
ln -srf "${file}" "${confname}"
done
systemd_dir="${conf_dir}/systemd/user"
mkdir -p "${systemd_dir}"
cd "${systemd_dir}"
for file in ${script_dir}/systemd/*
do
unitname="$(basename "${file}")"
echo "Linking ${file} -> $(pwd)/${unitname}"
ln -srf "${file}" "${unitname}"
done
systemctl --user daemon-reload
systemctl --user enable pacman-count.timer
systemctl --user enable random-wallpaper.timer
systemctl --user enable emacsd.service
}
( cd "${script_dir}" && git submodule init && git submodule update)
# ensure-deps
ensure-quicklisp
ensure-stumpwm
link-files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment