From 063e13b13f3f8da40b469e7d410ad6523882f78e Mon Sep 17 00:00:00 2001 From: emily Date: Mon, 13 May 2024 12:17:37 +0200 Subject: [PATCH] removed darwin from hydra and added reboot option to upgrade script --- config/services/hydra/nix-config.nix | 4 ++-- pkgs/upgrade-system/upgrade-system.sh | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/config/services/hydra/nix-config.nix b/config/services/hydra/nix-config.nix index c9e1177..c7aa778 100644 --- a/config/services/hydra/nix-config.nix +++ b/config/services/hydra/nix-config.nix @@ -5,7 +5,7 @@ sshUser = "hydra-queue-runner"; maxJobs = 40; speedFactor = 40; - systems = [ "x86_64-linux" "x86_64-darwin" ]; + systems = [ "x86_64-linux" ]; supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; sshKey = "/var/lib/hydra/id_ed25519"; } @@ -14,7 +14,7 @@ sshUser = "build"; maxJobs = 4; speedFactor = 8; - systems = [ "aarch64-linux" "aarch64-darwin" ]; + systems = [ "aarch64-linux" ]; supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; sshKey = "/var/lib/hydra/id_ed25519"; } diff --git a/pkgs/upgrade-system/upgrade-system.sh b/pkgs/upgrade-system/upgrade-system.sh index cb5d43d..086bc1b 100644 --- a/pkgs/upgrade-system/upgrade-system.sh +++ b/pkgs/upgrade-system/upgrade-system.sh @@ -2,6 +2,21 @@ set -euo pipefail +ALLOW_REBOOT= + +while [[ $# -gt 0 ]]; do + case $1 in + --allow-reboot) + ALLOW_REBOOT=1 + shift + ;; + *) + echo "Unknown option $1" + exit 1 + ;; + esac +done + HYDRA_URL="https://hydra.kyouma.net/job/infra/nixfiles/nixosConfigurations.${HOSTNAME}/latest-finished" NEW_STORE_PATH="$(curl --fail -s -L -H "Accept: application/json" "${HYDRA_URL}" | jq -r ".buildoutputs.out.path")" @@ -44,9 +59,14 @@ echo "Set new profile as boot target" nixos-needsreboot if [[ -f "/var/run/reboot-required" ]]; then - delay=$(echo -n $RANDOM | tail -c 2) - echo "Rebooting system in ${delay} Minutes" - shutdown -r +"${delay}" + if [[ -n "$ALLOW_REBOOT" ]]; then + delay=$(echo -n $RANDOM | tail -c 2) + echo "Rebooting system in ${delay} Minutes" + shutdown -r +"${delay}" + else + echo "Unattended reboot not allowed" + echo "Reboot system manually" + fi else echo "Activating system now" /nix/var/nix/profiles/system/bin/switch-to-configuration switch