From 7855552e06cdac73f9d705450b55ebc2db40d914 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 10 Jan 2022 04:14:45 +0100 Subject: [PATCH] lib/autoupdate: don't switch back to configurations without autoupdate --- lib/autoupdate.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/autoupdate.nix b/lib/autoupdate.nix index dff05f3e..5c518270 100644 --- a/lib/autoupdate.nix +++ b/lib/autoupdate.nix @@ -12,6 +12,12 @@ }; config = lib.mkIf config.c3d2.autoUpdate { + # the presence of this file signifies that the system is + # autoupdate-enabled. it is checked to prevent autoupdating back + # to a system without autoupdate when deploying with autoupdate + # for the first time. + environment.etc."autoupdated".text = ""; + systemd.services.autoupdate = { wantedBy = [ "multi-user.target" ]; path = with pkgs; [ nixFlakes nettools curl jq ]; @@ -28,8 +34,12 @@ echo "New system available: $NEW" # this should fetch the new system from the binary cache nix build --no-link "$NEW" - # switch to the new system - "$NEW/bin/switch-to-configuration" switch + if [ -e "$NEW/sw/etc/autoupdated" ]; then + # switch to the new system + "$NEW/bin/switch-to-configuration" switch + else + echo "New system is not yet autoupdated" + fi else echo "No update required" fi