pkgs/nixfiles: Ask before doing a system upgrade from Hydra
This commit is contained in:
parent
01b1ce3caa
commit
b37bdf88e1
@ -21,7 +21,7 @@ in
|
|||||||
systemd.services.nixfiles-system-auto-upgrade = {
|
systemd.services.nixfiles-system-auto-upgrade = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
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";
|
startAt = "*-*-* 06:47:00";
|
||||||
};
|
};
|
||||||
|
@ -3,17 +3,22 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ALLOW_REBOOT=
|
ALLOW_REBOOT=
|
||||||
|
NO_CONFIRM=
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--allow-reboot)
|
--allow-reboot)
|
||||||
ALLOW_REBOOT=1
|
ALLOW_REBOOT=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--no-confirm)
|
||||||
|
NO_CONFIRM=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option $1"
|
echo "Unknown option $1"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -22,6 +27,17 @@ HYDRA_JOB_URL="https://hydra.clerie.de/job/nixfiles/nixfiles/nixosConfigurations
|
|||||||
echo "Fetching job output from ${HYDRA_JOB_URL}"
|
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")"
|
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}"
|
echo "Download ${STORE_PATH}"
|
||||||
nix copy --from "https://nix-cache.clerie.de" "${STORE_PATH}"
|
nix copy --from "https://nix-cache.clerie.de" "${STORE_PATH}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user