local/bin/homeinit: Don't `guix pull' unless it has never been done before.
parent
28c2c5b07d
commit
b23f22b410
|
@ -38,7 +38,11 @@ Environment variables:
|
|||
XDG_DATA_HOME=$XDG_DATA_HOME
|
||||
XDG_BIN_HOME=$XDG_BIN_HOME
|
||||
|
||||
Tip: Copy the email cache to '$MAIL_CACHE' to speed up the process.
|
||||
Tip:
|
||||
|
||||
- Run `guix pull -C my-channels.scm' to run the Guix corresponding to your
|
||||
substitute server.
|
||||
- Copy the email cache to '$MAIL_CACHE' to speed up the process.
|
||||
|
||||
Direct link:
|
||||
|
||||
|
@ -204,51 +208,9 @@ popd
|
|||
section "System packages"
|
||||
if inpath guix; 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 --substitute-urls="$SUBSTITUTE_URLS"
|
||||
message "First Guix pull"
|
||||
guix pull --substitute-urls="$SUBSTITUTE_URLS"
|
||||
hash guix
|
||||
unset YESTERDAY_COMMIT
|
||||
rm -rf /tmp/guix
|
||||
elif $OPT_UPDATE; then
|
||||
CURRENT_COMMIT=$(guix describe -f recutils | recsel -P commit -e 'name = "guix"')
|
||||
for i in $HOME/.cache/guix/pull/*; do
|
||||
if [ "$(git -C "$i" config --get remote.origin.url)" = "https://git.savannah.gnu.org/git/guix.git" ]; then
|
||||
REPO="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
CURRENT_COMMIT_DATE=$(git -C "$REPO" log -n 1 --format=%ct $CURRENT_COMMIT)
|
||||
git -C $REPO pull
|
||||
hash guix
|
||||
LATEST_COMMIT_DATE=$(git -C "$REPO" log -n 1 --format=%ct)
|
||||
|
||||
[ -z "$GUIX_DISTRO_AGE_WARNING" ] && GUIX_DISTRO_AGE_WARNING=$((7 * 24 * 60 * 60))
|
||||
|
||||
info "Current commit date: $(date --date="@$CURRENT_COMMIT_DATE") ($CURRENT_COMMIT_DATE)"
|
||||
info "Last commit date: $(date --date="@$LATEST_COMMIT_DATE") ($LATEST_COMMIT_DATE)"
|
||||
info "Difference (in seconds): $(($LATEST_COMMIT_DATE - $CURRENT_COMMIT_DATE))"
|
||||
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 --substitute-urls="$SUBSTITUTE_URLS"
|
||||
unset YESTERDAY_COMMIT
|
||||
fi
|
||||
unset LATEST_COMMIT_DATE
|
||||
unset CURRENT_COMMIT_DATE
|
||||
unset REPO
|
||||
unset CURRENT_COMMIT
|
||||
else
|
||||
CURRENT_COMMIT=$(guix describe -f recutils | recsel -P commit -e 'name = "guix"')
|
||||
info "Guix pull commit $CURRENT_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 --substitute-urls="$SUBSTITUTE_URLS"
|
||||
|
|
Loading…
Reference in New Issue