local/bin/homeinit: Only override daemon's substitute URLS if passed as parameter.

master
Pierre Neidhardt 2020-06-17 11:06:55 +02:00
parent d71f9617a8
commit b97965b0bf
1 changed files with 23 additions and 6 deletions

View File

@ -10,6 +10,7 @@ ROOT=$HTTPS_ROOT
PROFILE=/tmp/homeinit-$USER/homeinit
USER_NAME=Ambrevar
SUBSTITUTE_URLS=https://ci.guix.gnu.org
EXTRA_SUBSTITUTE_URLS=
## Hardcoded in .mbsyncrc:
MAIL_CACHE="$HOME/.cache/mail"
@ -27,7 +28,7 @@ Initialize user profile: install packages, set up folders, etc.
Options:
-g DEVICE: Device where to sync ~/.gnupg from, e.g. '/dev/sda1'.
-u: Skip large updates (packages, emails, etc.)
-u: Skip large updates (large packages, email cache, etc.)
-s URLS: Extra substitute URLs for Guix (space separated).
Example: 'http://192.168.1.2:8080'.
@ -64,7 +65,7 @@ while getopts ":hg:s:u" opt; do
g)
OPT_DEVICE="$OPTARG" ;;
s)
SUBSTITUTE_URLS="$OPTARG $SUBSTITUTE_URLS" ;;
EXTRA_SUBSTITUTE_URLS="$OPTARG $EXTRA_SUBSTITUTE_URLS" ;;
u)
OPT_UPDATE=false ;;
\?)
@ -115,6 +116,22 @@ inpath() {
return 0
}
## Pass substitute URLs dynamically to avoid overriding the daemon settings.
run_guix() {
if [ -z "$EXTRA_SUBSTITUTE_URLS" ]; then
guix "$@"
else
guix --substitute-urls="$EXTRA_SUBSTITUTE_URLS $SUBSTITUTE_URLS" "$@"
fi
}
run_current_guix() {
if [ -z "$EXTRA_SUBSTITUTE_URLS" ]; then
~/.config/guix/current/bin/guix "$@"
else
~/.config/guix/current/bin/guix --substitute-urls="$EXTRA_SUBSTITUTE_URLS $SUBSTITUTE_URLS" "$@"
fi
}
################################################################################
#
@ -125,7 +142,7 @@ 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 recutils --substitute-urls="$SUBSTITUTE_URLS"
run_guix package --profile="$PROFILE" --install openssh gnupg git stow password-store pinentry-tty pinentry-gtk2 cryptsetup recutils
source "$PROFILE"/etc/profile
fi
@ -224,14 +241,14 @@ guix_install_profile() {
if [ -f "$manifest" ]; then
if [ "$1" = "default" ]; then
info "Installing default profile..."
~/.config/guix/current/bin/guix package --manifest="$manifest" --keep-failed --substitute-urls="$SUBSTITUTE_URLS"
run_current_guix package --manifest="$manifest" --keep-failed
. ~/.guix-profile/etc/profile
else
profile=$HOME/.guix-extra-profiles/$1/$1
if [ ! -d "$HOME/.guix-extra-profiles/$1/$1" ]; then
info "Installing profile '$profile'..."
mkdir -p $(dirname "$profile")
~/.config/guix/current/bin/guix package --manifest="$manifest" --keep-failed --profile="$profile" --substitute-urls="$SUBSTITUTE_URLS"
run_current_guix package --manifest="$manifest" --keep-failed --profile="$profile"
if [ -f "$profile"/etc/profile ]; then
. "$profile"/etc/profile
fi
@ -248,7 +265,7 @@ section "System packages"
if inpath guix; then
if [ ! -e ~/.cache/guix ]; then
message "First 'guix pull'"
guix pull --substitute-urls="$SUBSTITUTE_URLS"
run_guix pull
hash guix
fi