ENH pull deps from emacs and install with yay

This commit is contained in:
Nathan Dwarshuis 2021-03-13 20:31:06 -05:00
parent abaa7dd00e
commit 0a9d2f8e41
3 changed files with 98 additions and 55 deletions

View File

@ -15,6 +15,8 @@
## 7. remove the pacman sudo privilege for nobody ## 7. remove the pacman sudo privilege for nobody
pkgsrc_dir="$1" pkgsrc_dir="$1"
emacs_dir="$2"
makepkg_tmp=/tmp/bootstrap-makepkg makepkg_tmp=/tmp/bootstrap-makepkg
yaytmp=/tmp/bootstrap-yay yaytmp=/tmp/bootstrap-yay
nobody_sudo_conf="nobody ALL=(root) NOPASSWD: /usr/bin/pacman" nobody_sudo_conf="nobody ALL=(root) NOPASSWD: /usr/bin/pacman"
@ -54,11 +56,23 @@ call_makepkg() {
sudo -u nobody MAKEFLAGS="-j$(nproc)" makepkg -s -r -i -f --noconfirm sudo -u nobody MAKEFLAGS="-j$(nproc)" makepkg -s -r -i -f --noconfirm
} }
get_emacs_packages() {
emacs -batch -l "$emacs_dir/init.el" --eval \
"(print (s-join \" \" $1))" 2>/dev/null | \
sed -n -e 's/"\(.*\)"/\1/p'
}
run_yay() { run_yay() {
## TODO add template switches to control which of these get installed based ## TODO add template switches to control which of these get installed based
## on my config ## on my config
## packages for emacs (install emacs first to read the config)
pacman --needed -S emacs
IFS=' ' read -r -a emacs_pkgs \
< <(get_emacs_packages "(nd/get-aur-dependencies t)")
## other packages for random gizmos
dunst_pkgs=(dunst) dunst_pkgs=(dunst)
emacs_pkgs=(emacs mu)
flameshot_pkgs=(flameshot) flameshot_pkgs=(flameshot)
gtk_pkgs=(zuki-themes) gtk_pkgs=(zuki-themes)
nvidia_pkgs=(optimus-manager) nvidia_pkgs=(optimus-manager)
@ -78,7 +92,7 @@ run_yay() {
spotify_pkgs=(gconf) spotify_pkgs=(gconf)
sudo -u nobody HOME="$yaytmp" MAKEFLAGS="-j$(nproc)" \ sudo -u nobody HOME="$yaytmp" MAKEFLAGS="-j$(nproc)" \
yay --noconfirm --removemake -S \ yay --needed --noconfirm --removemake -S \
"${dunst_pkgs[@]}" \ "${dunst_pkgs[@]}" \
"${emacs_pkgs[@]}" \ "${emacs_pkgs[@]}" \
"${flameshot_pkgs[@]}" \ "${flameshot_pkgs[@]}" \
@ -133,8 +147,8 @@ if [[ ! "$(id -u)" = "0" ]]; then
exit 1 exit 1
fi fi
if [ "$#" -ne 1 ]; then if [ "$#" -ne 2 ]; then
echo "Must supply the location of custom packages as sole argument. Exiting" echo "Must supply custom package location and emacs root. Exiting"
exit 1 exit 1
fi fi

View File

@ -1,10 +1,84 @@
#! /bin/bash #! /bin/bash
## install all packages required for this configuration to function.
## Configuration is assumed to be handled elsewhere (for now) eg in etckeeper
## or with ansible.
## this just calls another bootstrap script as root, which allows me to only # This script installs all packages that my config needs. It also pulls all my
## require entering a sudo password once # git repos that I use in my config. It will only pull them if they don't
# exist. Rather than use the import approach suggested in the chezmoi howto,
# this doesn't require me to keep 'syncing' changes when I work in these repos
# directly. The tradeoff is that it will only pull the latest master, which is
# totally fine with me.
sudo "$HOME/.bin/bootstrap_pkgs" "$HOME/.local/share/packages" # Configuration is assumed to be handled elsewhere (for now) eg in etckeeper
# or with ansible.
clone_maybe () {
if [ ! -d "$2" ]; then
echo cloning git repo: "$1"
git clone --recurse-submodules "$1" "$2"
else
echo git repo already exists: "$1"
fi
}
run_stack_in_dir () {
local cur
cur="$(pwd)"
cd "$1" || return 1
stack install
cd "$cur" || return 1
}
#
# CLONE EMACS CONFIG
#
# do this before installing packages because its config will spit out
# dependencies that it needs to run at full capacity
emacs_dir="$HOME/.config/emacs"
clone_maybe https://github.com/ndwarshuis/.emacs.d.git "$emacs_dir"
## INSTALL PACKAGES
# The script that installs packages must be run as root, which allows sudo to
# only be used once. Pass the emacs config directory so it can get a list of
# dependencies for emacs
sudo "$HOME/.bin/bootstrap_pkgs" "$HOME/.local/share/packages" "$emacs_dir"
# Install Haskell dependencies for emacs. This is only necessary because some
# Haskell programs are not packaged as "bin" or "stack" packages, in which case
# arch will pull in a bunch of crap because dynamic linking
IFS=' ' read -r -a emacs_stack_pkgs \
< <(emacs -batch -l "$emacs_dir/init.el" --eval \
"(print (s-join \" \" (nd/get-stack-dependencies)))" 2>/dev/null | \
sed -n -e 's/"\(.*\)"/\1/p')
for p in "${emacs_stack_pkgs[@]}";
do
stack install "$p"
done
## CLONE/BUILD HASKELL-BASED REPOS
# TODO not dry (this is in .pam_environment)
# TODO could use tmp for this and it would probably be faster and get around
# the DRY problem, at the expense that build xmonad the first time live will
# be a PITA
export STACK_ROOT="$HOME/.local/share/stack"
rofix_dir="$HOME/.config/rofi-extras"
clone_maybe https://github.com/ndwarshuis/rofi-extras.git "$rofix_dir"
run_stack_in_dir "$rofix_dir"
xman_dir="$HOME/.config/xman"
clone_maybe https://github.com/ndwarshuis/xman.git "$xman_dir"
run_stack_in_dir "$xman_dir"
xmonad_dir="$HOME/.config/xmonad"
clone_maybe https://github.com/ndwarshuis/xmonad-config.git "$xmonad_dir"
run_stack_in_dir "$xmonad_dir"
## CLONE OTHER REPOS
clone_maybe https://github.com/ndwarshuis/conky.git "$HOME/.config/conky"

View File

@ -1,45 +0,0 @@
#! /bin/bash
## This script pulls all my git repos that I use in my config. It will only pull
## them if they don't exist. Rather than use the import approach suggested in
## the chezmoi howto, this doesn't require me to keep 'syncing' changes when I
## work in these repos directly. The tradeoff is that it will only pull the
## latest master, which is totally fine with me.
clone_maybe () {
if [ ! -d "$2" ]; then
echo cloning git repo: "$1"
git clone --recurse-submodules "$1" "$2"
else
echo git repo already exists: "$1"
fi
}
run_stack_in_dir () {
local cur
cur="$(pwd)"
cd "$1" || return 1
stack install
cd "$cur" || return 1
}
## TODO not dry
## TODO could use tmp for this and it would probably be faster and get around
## the DRY problem, at the expense that build xmonad the first time live will
## be a PITA
export STACK_ROOT="$HOME/.local/share/stack"
clone_maybe https://github.com/ndwarshuis/conky.git "$HOME/.config/conky"
clone_maybe https://github.com/ndwarshuis/.emacs.d.git "$HOME/.config/emacs"
rofix_dir="$HOME/.config/rofi-extras"
clone_maybe https://github.com/ndwarshuis/rofi-extras.git "$rofix_dir"
run_stack_in_dir "$rofix_dir"
xman_dir="$HOME/.config/xman"
clone_maybe https://github.com/ndwarshuis/xman.git "$xman_dir"
run_stack_in_dir "$xman_dir"
xmonad_dir="$HOME/.config/xmonad"
clone_maybe https://github.com/ndwarshuis/xmonad-config.git "$xmonad_dir"
run_stack_in_dir "$xmonad_dir"