1
0
Fork 0

pkgs/nixfiles: Ask before doing a system upgrade from Hydra

This commit is contained in:
clerie 2023-12-01 18:14:25 +01:00
parent 01b1ce3caa
commit b37bdf88e1
2 changed files with 19 additions and 3 deletions

View File

@ -21,7 +21,7 @@ in
systemd.services.nixfiles-system-auto-upgrade = {
serviceConfig = {
Type = "oneshot";
ExecStart = pkgs.nixfiles-system-upgrade + "/bin/nixfiles-system-upgrade${optionalString cfg.allowReboot " --allow-reboot"}";
ExecStart = pkgs.nixfiles-system-upgrade + "/bin/nixfiles-system-upgrade --no-confirm${optionalString cfg.allowReboot " --allow-reboot"}";
};
startAt = "*-*-* 06:47:00";
};

View File

@ -3,17 +3,22 @@
set -euo pipefail
ALLOW_REBOOT=
NO_CONFIRM=
while [[ $# -gt 0 ]]; do
case $1 in
--allow-reboot)
ALLOW_REBOOT=1
shift
;;
;;
--no-confirm)
NO_CONFIRM=1
shift
;;
*)
echo "Unknown option $1"
exit 1
;;
;;
esac
done
@ -22,6 +27,17 @@ HYDRA_JOB_URL="https://hydra.clerie.de/job/nixfiles/nixfiles/nixosConfigurations
echo "Fetching job output from ${HYDRA_JOB_URL}"
STORE_PATH="$(curl --fail -s -L -H "Accept: application/json" "${HYDRA_JOB_URL}" | jq -r ".buildoutputs.out.path")"
if [[ -z $NO_CONFIRM ]]; then
echo ""
echo " ! WARNING !"
echo ""
echo " You are about to upgrade ${HOSTNAME} to ${STORE_PATH}."
echo " This can be an older version than currently running on this system."
echo ""
read -e -r -p "Continue?" confirm
echo "$confirm" > /dev/null
fi
echo "Download ${STORE_PATH}"
nix copy --from "https://nix-cache.clerie.de" "${STORE_PATH}"