diff --git a/dot_bin/executable_bootstrap_pkgs b/dot_bin/executable_bootstrap_pkgs index b2fb418..a5c1625 100644 --- a/dot_bin/executable_bootstrap_pkgs +++ b/dot_bin/executable_bootstrap_pkgs @@ -15,6 +15,8 @@ ## 7. remove the pacman sudo privilege for nobody pkgsrc_dir="$1" +emacs_dir="$2" + makepkg_tmp=/tmp/bootstrap-makepkg yaytmp=/tmp/bootstrap-yay 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 } +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() { ## TODO add template switches to control which of these get installed based ## 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) - emacs_pkgs=(emacs mu) flameshot_pkgs=(flameshot) gtk_pkgs=(zuki-themes) nvidia_pkgs=(optimus-manager) @@ -78,7 +92,7 @@ run_yay() { spotify_pkgs=(gconf) sudo -u nobody HOME="$yaytmp" MAKEFLAGS="-j$(nproc)" \ - yay --noconfirm --removemake -S \ + yay --needed --noconfirm --removemake -S \ "${dunst_pkgs[@]}" \ "${emacs_pkgs[@]}" \ "${flameshot_pkgs[@]}" \ @@ -133,8 +147,8 @@ if [[ ! "$(id -u)" = "0" ]]; then exit 1 fi -if [ "$#" -ne 1 ]; then - echo "Must supply the location of custom packages as sole argument. Exiting" +if [ "$#" -ne 2 ]; then + echo "Must supply custom package location and emacs root. Exiting" exit 1 fi diff --git a/run_once_after_10_install-packages.sh b/run_once_after_10_install-packages.sh index 59af2d3..f54e75f 100644 --- a/run_once_after_10_install-packages.sh +++ b/run_once_after_10_install-packages.sh @@ -1,10 +1,84 @@ #! /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 -## require entering a sudo password once +# This script installs all packages that my config needs. It also 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. -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" diff --git a/run_once_after_50_clone-repos.sh b/run_once_after_50_clone-repos.sh deleted file mode 100644 index 4caec18..0000000 --- a/run_once_after_50_clone-repos.sh +++ /dev/null @@ -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"