local/bin/homeinit: Replace COMMAND by INPATH

master
Pierre Neidhardt 2019-01-22 11:24:35 +01:00
parent 7c6c47b1e4
commit f1ff9a7460
1 changed files with 23 additions and 15 deletions

View File

@ -1,12 +1,12 @@
#!/bin/sh
# TODO: Make "command -v " wrapper with support for multiple arguments.
# TODO: Create a separate profile in /tmp to install gnupg, git, etc. then delete it when it's over.
# TODO: Run guix pull if OPT_UPDATE and if guix chekout is more than some days old, as specified by an environment variable.
# TODO: Guix pull on commit specified in package-lists/guix-version?
# TODO: On foreign distro, use local package manager to install Guix. (Start with pacman.)
# TODO: Test if TTY and set pinentry appropriately without clobbering
# ~/.gnupg/gpg-agent.conf
# TODO: Run guix pull if OPT_UPDATE and if guix chekout is more than some days old, as specified by an environment variable.
# TODO: Guix pull on commit specified in package-lists/guix-version?
# TODO: On foreign distro, use local package manager to install Guix. (Start with pacman.)
# TODO: Make functions to make it easier to re-order calls?
HTTPS_ROOT=https://gitlab.com/
@ -76,14 +76,23 @@ lnn() { # $1=TARGET $2=LINK|FOLDER
fi
}
inpath() {
for i; do
if ! command -v "$i" >/dev/null 2>&1; then
return false
fi
done
return true
}
################################################################################
#
section "Initial packages"
if command -v guix >/dev/null 2>&1; then
if inpath guix; then
## TODO: Should openssh be an input of Git?
guix package --install openssh gnupg git stow password-store
elif command -v pacman >/dev/null 2>&1; then
elif inpath pacman; then
sudo pacman --noconfirm -S --needed openssh gnupg git stow password-store
fi
@ -131,25 +140,25 @@ stow -v . || exit 1
popd
section "System packages"
if command -v guix >/dev/null 2>&1; then
if inpath guix; then
## TODO: The manifest will uninstall other unspecified packages. Is this
## really what we want?
export GUIX_PACKAGE_PATH=$HOME/.guix-packages
guix package --manifest=$HOME/.package-lists/guix-manifest.scm --keep-failed
elif command -v pacman >/dev/null 2>&1; then
elif inpath pacman; then
pacman_list=""
if [ -f ~/.package-lists/arch-official ]; then
pacman_list="$(cat ~/.package-lists/arch-official)"
fi
sudo pacman --noconfirm -S --needed base base-devel $pacman_list
if ! command -v cower >/dev/null 2>&1; then
if ! inpath cower; 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
if ! inpath pacaur; then
mkdir -p /tmp
cower -d pacaur
pushd /tmp/pacaur
@ -166,15 +175,14 @@ elif command -v pacman >/dev/null 2>&1; then
fi
section "Bookmarks"
if command -v qutebrowser >/dev/null 2>&1; then
if inpath qutebrowser; then
mkdir -pv "$XDG_CONFIG_HOME/qutebrowser/bookmarks"
lnn "$SOURCEDIR/bookmarks/bookmarks" "$XDG_CONFIG_HOME/qutebrowser/bookmarks/urls"
lnn "$SOURCEDIR/bookmarks/quickmarks" "$XDG_CONFIG_HOME/qutebrowser/"
fi
section "Emacs"
if ! command -v emacs >/dev/null 2>&1 || \
[ $(emacs --quick --batch --eval '(message "%s" emacs-major-version)' 2>&1) -lt $EMACS_MIN_VERSION ]; then
if ! inpath emacs; then
message "Emacs: Installing latest development version"
pushd "$HOME/projects"
[ -e emacs ] || git clone https://git.savannah.gnu.org/git/emacs.git
@ -204,10 +212,10 @@ if ! command -v emacs >/dev/null 2>&1 || \
popd
fi
if command -v emacs >/dev/null 2>&1; then
if inpath emacs; then
message "Emacs cache folder"
mkdir -pv "$HOME/.cache/emacs/"
if ! command -v guix >/dev/null 2>&1; then
if ! inpath guix; then
if $OPT_UPDATE; then
message "Emacs ELPA packages"
yes | emacs --batch -l ~/.emacs.d/init.el --eval '(progn (package-refresh-contents) (package-install-selected-packages))'