2012-07-28 19:39:12 +02:00
|
|
|
#!/bin/sh
|
2018-05-18 12:05:05 +02:00
|
|
|
## Initialize and update user profile.
|
2014-11-12 16:15:39 +01:00
|
|
|
|
2017-05-05 20:29:00 +02:00
|
|
|
if [ "$1" = "-h" ]; then
|
|
|
|
cat <<EOF>&2
|
|
|
|
Usage: ${0##*/}
|
|
|
|
|
|
|
|
Initialize home folder.
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
2018-02-11 20:00:14 +01:00
|
|
|
-u: Skip large updates (packages, etc.)
|
2017-05-05 20:29:00 +02:00
|
|
|
|
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2018-02-11 20:00:14 +01:00
|
|
|
OPT_UPDATE=true
|
2017-05-05 20:29:00 +02:00
|
|
|
if [ "$1" = "-u" ]; then
|
2018-02-11 20:00:14 +01:00
|
|
|
OPT_UPDATE=false
|
2017-05-05 20:29:00 +02:00
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2016-10-12 11:03:57 +02:00
|
|
|
SOURCEDIR="$HOME/personal"
|
2012-10-29 15:29:54 +01:00
|
|
|
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
[ -z "$XDG_DATA_HOME" ] && XDG_DATA_HOME="$HOME/.local/share"
|
2012-07-28 20:04:21 +02:00
|
|
|
|
2017-07-24 18:25:31 +02:00
|
|
|
## ln no-clobber
|
|
|
|
lnn() {
|
2018-01-11 11:19:20 +01:00
|
|
|
if [ -d "$2" ]; then
|
|
|
|
set -- "$1" "$2/$(basename "$1")"
|
|
|
|
fi
|
2017-07-24 18:25:31 +02:00
|
|
|
if [ ! -e "$2" ] || [ -h "$2" ]; then
|
|
|
|
ln -svnf "$1" "$2"
|
|
|
|
fi
|
|
|
|
}
|
2013-05-04 00:30:11 +02:00
|
|
|
|
2018-05-18 12:05:05 +02:00
|
|
|
echo "==> Initial packages"
|
|
|
|
if command -v pacman >/dev/null 2>&1; then
|
|
|
|
sudo pacman --noconfirm -S --needed gnupg git stow
|
|
|
|
elif command -v guix >/dev/null 2>&1; then
|
|
|
|
guix package --install gnupg git stow
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "==> GPG"
|
|
|
|
if [ -d ~/.gnupg ]; then
|
|
|
|
chmod go-rwx ~/.gnupg ~/.gnupg/*
|
2018-05-18 12:32:48 +02:00
|
|
|
if [ -e "$SOURCEDIR" ]; then
|
|
|
|
git -C "$SOURCEDIR" pull
|
|
|
|
else
|
|
|
|
git clone git@gitlab.com:Ambrevar/personal
|
|
|
|
fi
|
|
|
|
if [ -e ~/.password-store ]; then
|
|
|
|
git -C ~/.password-store pull
|
|
|
|
else
|
|
|
|
git clone git@gitlab.com:Ambrevar/password-store ~/.password-store
|
2018-07-12 12:02:07 +02:00
|
|
|
## The following is necessary to make sure the 'diff' GPG filter is properly set up.
|
|
|
|
pass git init
|
2018-05-18 12:32:48 +02:00
|
|
|
fi
|
2018-05-18 12:05:05 +02:00
|
|
|
else
|
|
|
|
echo "~/.gnupg not found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "==> Persistent folders"
|
|
|
|
for i in .emacs.d .local/share projects temp; do
|
|
|
|
mkdir -pv "$HOME/$i"
|
|
|
|
done
|
|
|
|
|
2018-05-21 12:55:21 +02:00
|
|
|
## TODO: Remove .bash_profile?
|
2018-05-18 12:05:05 +02:00
|
|
|
echo "==> dotfiles"
|
|
|
|
if [ -e ~/dotfiles ]; then
|
2018-05-18 12:32:48 +02:00
|
|
|
git -C ~/dotfiles remote set-url origin git@github.com:Ambrevar/dotfiles
|
|
|
|
git -C ~/dotfiles pull
|
2018-05-18 12:05:05 +02:00
|
|
|
else
|
|
|
|
git clone git@github.com:Ambrevar/dotfiles
|
|
|
|
fi
|
|
|
|
pushd ~/dotfiles
|
|
|
|
stow -v .
|
|
|
|
popd
|
2017-07-29 10:31:30 +02:00
|
|
|
|
2018-01-11 11:06:43 +01:00
|
|
|
echo "==> System packages"
|
|
|
|
if command -v pacman >/dev/null 2>&1; then
|
|
|
|
pacman_list=""
|
|
|
|
if [ -f ~/.pkglists/arch-official ]; then
|
|
|
|
pacman_list="$(cat ~/.pkglists/arch-official)"
|
|
|
|
fi
|
|
|
|
sudo pacman --noconfirm -S --needed base base-devel $pacman_list
|
|
|
|
if ! command -v cower >/dev/null 2>&1; then
|
|
|
|
mkdir -p /tmp/cower
|
|
|
|
pushd /tmp/cower
|
|
|
|
curl https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=cower > PKGBUILD
|
|
|
|
makepkg --noconfirm -si
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
if ! command -v pacaur >/dev/null 2>&1; then
|
|
|
|
mkdir -p /tmp
|
|
|
|
cower -d pacaur
|
|
|
|
pushd /tmp/pacaur
|
|
|
|
makepkg --noconfirm -si
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
if $OPT_UPDATE && [ -f ~/.pkglists/arch-aur ]; then
|
|
|
|
pacaur --noconfirm --noedit -y --needed "$(cat ~/.pkglists/arch-aur)"
|
|
|
|
fi
|
2018-01-11 11:32:28 +01:00
|
|
|
pacman_list=$(pacman -Qdtq)
|
|
|
|
if [ -n "$pacman_list" ]; then
|
|
|
|
sudo pacman --noconfirm -Rs "$pacman_list"
|
|
|
|
fi
|
2018-05-18 12:32:48 +02:00
|
|
|
elif command -v guix >/dev/null 2>&1; then
|
2018-05-21 12:55:21 +02:00
|
|
|
## TODO: The manifest will uninstall other unspecified packages. Is this
|
|
|
|
## really what we want?
|
2018-05-18 12:32:48 +02:00
|
|
|
guix package --manifest=~/.pkglists/guix
|
2018-01-11 11:06:43 +01:00
|
|
|
fi
|
|
|
|
|
2016-05-31 10:43:04 +02:00
|
|
|
echo "==> Bookmarks"
|
2017-07-09 00:08:45 +02:00
|
|
|
mkdir -pv "$XDG_CONFIG_HOME/qutebrowser/bookmarks"
|
2017-07-24 18:25:31 +02:00
|
|
|
lnn "$SOURCEDIR/bookmarks/bookmarks" "$XDG_CONFIG_HOME/qutebrowser/bookmarks/urls"
|
|
|
|
lnn "$SOURCEDIR/bookmarks/quickmarks" "$XDG_CONFIG_HOME/qutebrowser/"
|
2013-01-09 19:25:23 +01:00
|
|
|
|
2018-05-18 12:05:05 +02:00
|
|
|
if ! command -v emacs >/dev/null 2>&1 || \
|
2018-03-27 07:56:13 +02:00
|
|
|
[ $(emacs --quick --batch --eval '(message "%s" emacs-major-version)' 2>&1) -lt 26 ]; then
|
2018-05-18 12:05:05 +02:00
|
|
|
pushd "$HOME/projects"
|
|
|
|
[ -e emacs ] || git clone https://git.savannah.gnu.org/git/emacs.git
|
|
|
|
if command -v guix >/dev/null 2>&1; then
|
|
|
|
guix package --install emacs-dev
|
|
|
|
else
|
2018-03-29 08:53:01 +02:00
|
|
|
mkdir -p ../emacs-build
|
|
|
|
cd ../emacs-build
|
|
|
|
../emacs/configure \
|
|
|
|
--disable-gtk-deprecation-warnings \
|
|
|
|
--without-pop \
|
|
|
|
--without-kerberos \
|
|
|
|
--without-kerberos5 \
|
|
|
|
--with-x-toolkit=gtk3 \
|
|
|
|
--with-jpeg \
|
|
|
|
--with-tiff \
|
|
|
|
--with-gif \
|
|
|
|
--with-png \
|
|
|
|
--with-rsvg \
|
|
|
|
--with-xml2 \
|
|
|
|
--with-imagemagick \
|
|
|
|
--with-xft \
|
|
|
|
--with-libotf \
|
|
|
|
--without-gsettings \
|
|
|
|
--without-gconf \
|
|
|
|
--with-gnutls \
|
|
|
|
--with-modules \
|
|
|
|
--with-threads
|
|
|
|
popd
|
|
|
|
sudo make install
|
|
|
|
fi
|
2018-02-16 14:18:28 +01:00
|
|
|
fi
|
|
|
|
|
2017-07-24 18:25:31 +02:00
|
|
|
if command -v emacs >/dev/null 2>&1; then
|
2018-02-16 14:18:28 +01:00
|
|
|
mkdir -pv "$HOME/.cache/emacs/"
|
2018-05-18 12:05:05 +02:00
|
|
|
if ! command -v guix >/dev/null 2>&1; then
|
|
|
|
if $OPT_UPDATE; then
|
|
|
|
echo "==> Emacs ELPA packages"
|
|
|
|
yes | emacs --batch -l ~/.emacs.d/init.el --eval '(progn (package-refresh-contents) (package-install-selected-packages))'
|
|
|
|
fi
|
2018-01-11 11:06:43 +01:00
|
|
|
fi
|
2017-10-26 19:12:18 +02:00
|
|
|
echo "==> Emacs extra packages"
|
2018-05-18 11:33:53 +02:00
|
|
|
mkdir -pv ~/.local/share/emacs/site-lisp
|
2018-05-18 12:05:05 +02:00
|
|
|
for i in ~/.local/share/emacs/site-lisp/*; do
|
2018-05-18 12:32:48 +02:00
|
|
|
echo "$i"
|
|
|
|
git -C "$i" pull
|
2018-05-18 12:05:05 +02:00
|
|
|
done
|
2016-05-06 09:24:40 +02:00
|
|
|
fi
|
2016-06-09 21:32:07 +02:00
|
|
|
|
2017-07-24 18:25:31 +02:00
|
|
|
echo "==> Mail"
|
|
|
|
lnn "$SOURCEDIR/mail/mbsyncrc" "$HOME/.mbsyncrc"
|
2018-02-08 18:01:18 +01:00
|
|
|
lnn "$SOURCEDIR/mail/authinfo.gpg" "$HOME/.authinfo.gpg"
|
2017-07-24 18:25:31 +02:00
|
|
|
mkdir -pv "$HOME/.cache/mail/"
|
2018-05-18 12:05:05 +02:00
|
|
|
while IFS= read -r i; do
|
|
|
|
## We get a shell command, so we need to evaluate it to expand "~".
|
|
|
|
eval "$i"
|
|
|
|
done <<EOF
|
2017-07-29 10:31:30 +02:00
|
|
|
$(awk '/^Path/ {$1="mkdir -pv"; print}' ~/.mbsyncrc)
|
2017-07-24 18:25:31 +02:00
|
|
|
EOF
|
2017-07-29 10:31:30 +02:00
|
|
|
|
2018-01-11 11:06:43 +01:00
|
|
|
if $OPT_UPDATE; then
|
|
|
|
mbsync -aV
|
|
|
|
mu index --maildir=~/.cache/mail
|
|
|
|
fi
|