local/bin/homeinit: Fix -u argument and support substitute URLs.
parent
0aefafb713
commit
918b713438
|
@ -9,6 +9,7 @@ SSH_ROOT=git@gitlab.com:
|
|||
ROOT=$HTTPS_ROOT
|
||||
PROFILE=/tmp/homeinit-$USER/homeinit
|
||||
USER_NAME=Ambrevar
|
||||
SUBSTITUTE_URLS=https://ci.guix.gnu.org
|
||||
|
||||
[ -z "$SOURCEDIR" ] && SOURCEDIR="$HOME/personal"
|
||||
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
||||
|
@ -25,6 +26,8 @@ Options:
|
|||
|
||||
-g DEVICE: Device where to sync ~/.gnupg.
|
||||
-u: Skip large updates (packages, emails, etc.)
|
||||
-s URLS: Extra substitute URLs for Guix (space separated).
|
||||
Example: 'http://192.168.1.2:8080'.
|
||||
|
||||
Environment variables:
|
||||
|
||||
|
@ -42,15 +45,17 @@ EOF
|
|||
|
||||
OPT_UPDATE=true
|
||||
OPT_DEVICE=""
|
||||
while getopts ":hg:u" opt; do
|
||||
while getopts ":hg:s:u" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit ;;
|
||||
g)
|
||||
OPT_DEVICE="$OPTARG" ;;
|
||||
s)
|
||||
SUBSTITUTE_URLS="$OPTARG $SUBSTITUTE_URLS" ;;
|
||||
u)
|
||||
OPT_UPDATE=true ;;
|
||||
OPT_UPDATE=false ;;
|
||||
\?)
|
||||
usage
|
||||
exit 1 ;;
|
||||
|
@ -109,12 +114,15 @@ if inpath guix; then
|
|||
## OpenSSH is not an input of Git, upstream does not want to increase the
|
||||
## closure size that much.
|
||||
mkdir -p "$(dirname "$PROFILE")"
|
||||
guix package --profile="$PROFILE" --install openssh gnupg git stow password-store pinentry-tty pinentry-gtk2 cryptsetup
|
||||
guix package --profile="$PROFILE" --install openssh gnupg git stow password-store pinentry-tty pinentry-gtk2 cryptsetup --substitute-urls="$SUBSTITUTE_URLS"
|
||||
source "$PROFILE"/etc/profile
|
||||
fi
|
||||
|
||||
has_gpg_keys() {
|
||||
[ -n "$(ls -1 ~/.gnupg/private-*)" ]
|
||||
}
|
||||
|
||||
if [ ! -d ~/.gnupg ]; then
|
||||
if ! has_gpg_keys; then
|
||||
section "GPG sync"
|
||||
if [ -n "$OPT_DEVICE" ]; then
|
||||
section "GnuPG"
|
||||
|
@ -129,7 +137,7 @@ if [ ! -d ~/.gnupg ]; then
|
|||
fi
|
||||
|
||||
section "GPG"
|
||||
if [ -d ~/.gnupg ]; then
|
||||
if has_gpg_keys; then
|
||||
ROOT=$SSH_ROOT
|
||||
## Set up gpg-agent to authenticate to SSH_ROOT.
|
||||
chmod -R go-rwx ~/.gnupg
|
||||
|
@ -171,7 +179,7 @@ else
|
|||
fi
|
||||
|
||||
section "Persistent folders"
|
||||
for i in .cache/mail .config .config/guix .config/transmission-daemon .emacs.d .local/share .mpv projects temp; do
|
||||
for i in .cache/mail .config .config/guix .config/transmission-daemon .emacs.d .local/share .mpv projects; do
|
||||
mkdir -pv "$HOME/$i"
|
||||
done
|
||||
|
||||
|
@ -190,14 +198,14 @@ popd
|
|||
|
||||
section "System packages"
|
||||
if inpath guix; then
|
||||
if [ ! -e ~/.cache/guix/pull ]; then
|
||||
if [ ! -e ~/.cache/guix ]; then
|
||||
message "Update Guix to yesterday's version"
|
||||
## TODO: This clones the repository twice, which is a bit dumb, but cloning
|
||||
## locally and then running `guix pull --url=/tmp/guix` produces a different
|
||||
## hash in ~/.cache/guix/...
|
||||
git clone https://git.savannah.gnu.org/git/guix.git /tmp/guix
|
||||
YESTERDAY_COMMIT=$(git -C /tmp/guix log --until=yesterday -n 1 --format=%H)
|
||||
guix pull --commit=$YESTERDAY_COMMIT
|
||||
guix pull --commit=$YESTERDAY_COMMIT --substitute-urls="$SUBSTITUTE_URLS"
|
||||
hash guix
|
||||
unset YESTERDAY_COMMIT
|
||||
rm -rf /tmp/guix
|
||||
|
@ -223,22 +231,29 @@ if inpath guix; then
|
|||
if [ $(($LATEST_COMMIT_DATE - $CURRENT_COMMIT_DATE)) -gt $GUIX_DISTRO_AGE_WARNING ]; then
|
||||
message "Update Guix since it's older than GUIX_DISTRO_AGE_WARNING ($GUIX_DISTRO_AGE_WARNING)."
|
||||
YESTERDAY_COMMIT=$(git -C "$REPO" log --until=yesterday -n 1 --format=%H)
|
||||
guix pull --commit=$YESTERDAY_COMMIT
|
||||
guix pull --commit=$YESTERDAY_COMMIT --substitute-urls="$SUBSTITUTE_URLS"
|
||||
unset YESTERDAY_COMMIT
|
||||
fi
|
||||
unset LATEST_COMMIT_DATE
|
||||
unset CURRENT_COMMIT_DATE
|
||||
unset REPO
|
||||
unset CURRENT_COMMIT
|
||||
else
|
||||
## REVIEW: Which one is the best way to retrieve the current commit?
|
||||
commit=$(guix describe -p ~/.config/guix/current | awk '/commit:/ {print $2}')
|
||||
info "Guix pull commit $commit with extra channels:"
|
||||
awk '/\(name/ {gsub(/['"'"')]/, ""); print $2}' ~/.config/guix/channels.scm
|
||||
guix pull --commit=$commit --substitute-urls="$SUBSTITUTE_URLS"
|
||||
unset commit
|
||||
fi
|
||||
|
||||
~/.config/guix/current/bin/guix package --manifest=$HOME/.package-lists/guix-default-manifest.scm --keep-failed
|
||||
~/.config/guix/current/bin/guix package --manifest=$HOME/.package-lists/guix-default-manifest.scm --keep-failed --substitute-urls="$SUBSTITUTE_URLS"
|
||||
. ~/.guix-profile/etc/profile
|
||||
|
||||
for i in main emacs texlive; do
|
||||
profile=$HOME/.guix-extra-profiles/$i/$i
|
||||
mkdir -p $(dirname "$profile")
|
||||
~/.config/guix/current/bin/guix package --manifest=$HOME/.package-lists/guix-$i-manifest.scm --keep-failed --profile="$profile"
|
||||
~/.config/guix/current/bin/guix package --manifest=$HOME/.package-lists/guix-$i-manifest.scm --keep-failed --profile="$profile" --substitute-urls="$SUBSTITUTE_URLS"
|
||||
if [ -f "$profile"/etc/profile ]; then
|
||||
. "$profile"/etc/profile
|
||||
fi
|
||||
|
@ -271,7 +286,7 @@ if inpath qutebrowser; then
|
|||
fi
|
||||
|
||||
section "Emacs"
|
||||
if ! inpath emacs; then
|
||||
if $OPT_UPDATE && ! inpath emacs; then
|
||||
message "Emacs: Installing latest development version"
|
||||
pushd "$HOME/projects"
|
||||
[ -e emacs ] || git clone https://git.savannah.gnu.org/git/emacs.git
|
||||
|
@ -338,7 +353,7 @@ if [ -f ~/personal/history/eshell.gpg ]; then
|
|||
fi
|
||||
|
||||
section "Mail"
|
||||
# lnn "$SOURCEDIR/mail/authinfo.gpg" "$HOME/.authinfo.gpg" ## Only if no using password-store.
|
||||
# lnn "$SOURCEDIR/mail/authinfo.gpg" "$HOME/.authinfo.gpg" ## Only if not using password-store.
|
||||
mkdir -pv "$HOME/.cache/mail/"
|
||||
while IFS= read -r i; do
|
||||
## Warning: We need to eval here to expand the "~".
|
||||
|
|
Loading…
Reference in New Issue