local/bin/homeinit: Run guix pull automatically
parent
f35e99105c
commit
23008a1480
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# 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: 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: On foreign distro, use local package manager to install Guix. (Start with pacman.)
|
||||||
# TODO: Make functions to make it easier to re-order calls?
|
# TODO: Make functions to make it easier to re-order calls?
|
||||||
|
@ -158,6 +156,35 @@ popd
|
||||||
|
|
||||||
section "System packages"
|
section "System packages"
|
||||||
if inpath guix; then
|
if inpath guix; then
|
||||||
|
if [ ! -e ~/.cache/guix/pull ]; then
|
||||||
|
message "Update Guix to yesterday's version"
|
||||||
|
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
|
||||||
|
unset YESTERDAY_COMMIT
|
||||||
|
rm -rv /tmp/guix
|
||||||
|
elif $OPT_UPDATE
|
||||||
|
CURRENT_COMMIT=$(guix --version 2>/dev/null | awk '{print $4; exit}')
|
||||||
|
REPO=$HOME/.cache/guix/pull/"$(ls -1 ~/.cache/guix/pull)"
|
||||||
|
CURRENT_COMMIT_DATE=git -C "$REPO" log -n 1 --format=%ct $CURRENT_COMMIT
|
||||||
|
git -C $REPO pull
|
||||||
|
LATEST_COMMIT_DATE=git -C "$REPO" log -n 1 --format=%ct
|
||||||
|
|
||||||
|
[ -z "$GUIX_DISTRO_AGE_WARNING" ] && GUIX_DISTRO_AGE_WARNING=$((7 * 24 * 60 * 60))
|
||||||
|
|
||||||
|
if [ $(($LATEST_COMMIT_DATE - $CURRENT_COMMIT)) -gt $GUIX_DISTRO_AGE_WARNING ]; then
|
||||||
|
message "Update Guix since it's older than a week."
|
||||||
|
YESTERDAY_COMMIT=$(git -C "$REPO" log --until=yesterday -n 1 --format=%H)
|
||||||
|
guix pull --commit=$YESTERDAY_COMMIT
|
||||||
|
unset YESTERDAY_COMMIT
|
||||||
|
fi
|
||||||
|
unset LATEST_COMMIT_DATE
|
||||||
|
unset CURRENT_COMMIT_DATE
|
||||||
|
unset REPO
|
||||||
|
unset CURRENT_COMMIT
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
## TODO: The manifest will uninstall other unspecified packages. Is this
|
## TODO: The manifest will uninstall other unspecified packages. Is this
|
||||||
## really what we want?
|
## really what we want?
|
||||||
export GUIX_PACKAGE_PATH=$HOME/.guix-packages
|
export GUIX_PACKAGE_PATH=$HOME/.guix-packages
|
||||||
|
|
Loading…
Reference in New Issue