autoupdate: unify scripts, hardcode hostname from config
This commit is contained in:
parent
03cbfb029f
commit
53fce8e2c7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user