From 53fce8e2c76d5b6898719e3deb21eff98d7c3a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 12 Jun 2022 16:24:44 +0200 Subject: [PATCH] autoupdate: unify scripts, hardcode hostname from config --- modules/autoupdate.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/autoupdate.nix b/modules/autoupdate.nix index 6987f89d..e677265e 100644 --- a/modules/autoupdate.nix +++ b/modules/autoupdate.nix @@ -27,18 +27,20 @@ }; script = '' OLD=$(readlink /run/current-system) - NEW=$(curl -sLH "Accept: application/json" https://hydra.hq.c3d2.de/job/c3d2/nix-config/$(hostname)/latest | jq -r .buildoutputs.out.path) + echo Current system: $(basename $OLD) + NEW=$(curl -sLH "Accept: application/json" https://hydra.hq.c3d2.de/job/c3d2/nix-config/${config.networking.hostName}/latest | jq -r .buildoutputs.out.path) if [ -z "$NEW" ] || [ "$NEW" = "null" ]; then echo "Unable to obtain updated system" exit 1 fi + echo New system: $(basename $NEW) if [ "$OLD" != "$NEW" ]; then - echo "New system available: $NEW" + echo "Fetching new system built by https://hydra.hq.c3d2.de/jobset/c3d2/nix-config" # this should fetch the new system from the binary cache nix copy --from https://nix-serve.hq.c3d2.de "$NEW" if [ -e "$NEW/etc/systemd/system/autoupdate.timer" ]; then - # switch to the new system + echo "Switch to the new system..." "$NEW/bin/switch-to-configuration" switch else echo "New system is not yet autoupdate-enabled. Refusing to switch into a dead end." @@ -76,7 +78,7 @@ OLD=$(readlink /run/current-system) echo Current system: $(basename $OLD) - NEW=$(curl -sLH "Accept: application/json" https://hydra.hq.c3d2.de/job/c3d2/nix-config/$(hostname)/latest | ${pkgs.jq}/bin/jq -r .buildoutputs.out.path) + NEW=$(curl -sLH "Accept: application/json" https://hydra.hq.c3d2.de/job/c3d2/nix-config/${config.networking.hostName}/latest | ${pkgs.jq}/bin/jq -r .buildoutputs.out.path) if [ -z "$NEW" ] || [ "$NEW" = "null" ]; then echo "Unable to obtain updated system" exit 1