diff options
Diffstat (limited to '')
| -rwxr-xr-x | scripts/check.sh | 54 | ||||
| -rw-r--r-- | scripts/check_get_tests.nix | 16 | ||||
| -rw-r--r-- | scripts/update_hosts.remote | 4 | ||||
| -rwxr-xr-x | scripts/update_hosts.sh | 9 |
4 files changed, 60 insertions, 23 deletions
diff --git a/scripts/check.sh b/scripts/check.sh index f152cbb..dbfa67d 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,20 +1,38 @@ #! /usr/bin/env sh -# --log-format multiline-with-logs \ -nix build \ - --option max-jobs 1 \ - --print-out-paths --no-link \ - .#checks.x86_64-linux.atuin-sync \ - .#checks.x86_64-linux.back \ - .#checks.x86_64-linux.deploy-activate \ - .#checks.x86_64-linux.deploy-schema \ - .#checks.x86_64-linux.dns \ - .#checks.x86_64-linux.formatting \ - .#checks.x86_64-linux.git-server \ - .#checks.x86_64-linux.rust-motd \ - .#checks.x86_64-linux.sharkey \ - .#checks.x86_64-linux.sharkey-cpu \ - .#checks.x86_64-linux.taskchampion-sync -# .#checks.x86_64-linux.email-dns \ -# .#checks.x86_64-linux.email-http \ -# .#checks.x86_64-linux.email-ip \ +git_root="$(git rev-parse --show-toplevel)" + +fmt_check() { + echo ".#checks.x86_64-linux.$1" +} + +failed="$(mktemp -t server_check_XXXXX)" +trap 'rm -f "$failed"' EXIT +trap 'exit 4' HUP INT QUIT TERM + +# We want word-splitting for the arg +# shellcheck disable=SC2046 +set -- $(nix eval --file "$git_root/scripts/check_get_tests.nix" --raw) + +while [ "$#" -ne 0 ]; do + test="$1" + shift 1 + + echo "Building test '$test'..." + fmt_test="$(fmt_check "$test")" + + if ! nix build \ + --option max-jobs 1 \ + --print-out-paths \ + --no-link \ + "$fmt_test"; then + echo "$test" >>"$failed" + fi +done + +if [ "$(cat "$failed" | wc -l)" -ne 0 ]; then + echo "Failed tests:" + while read -r test; do + echo " - $test" + done <"$failed" +fi diff --git a/scripts/check_get_tests.nix b/scripts/check_get_tests.nix new file mode 100644 index 0000000..a39d300 --- /dev/null +++ b/scripts/check_get_tests.nix @@ -0,0 +1,16 @@ +let + get = input: (builtins.fetchTree input.locked).outPath; + + lock = (builtins.fromJSON (builtins.readFile ../flake.lock)).nodes; + + flake-compat = import (get lock.flake-compat) {src = ../.;}; + pkgs = import (get lock.nixpkgs) {}; + inherit (pkgs) lib; + + inherit (flake-compat) outputs; +in + lib.strings.concatStringsSep "\n" + (builtins.attrNames + (lib.filterAttrs + (name: test: test.meta.broken == false) + outputs.checks.x86_64-linux)) diff --git a/scripts/update_hosts.remote b/scripts/update_hosts.remote index 7323a33..249b24e 100644 --- a/scripts/update_hosts.remote +++ b/scripts/update_hosts.remote @@ -27,7 +27,7 @@ PATH_add lixPackageSets.latest.lix # We might or might not have python, and we need it, because we use the unwrapped # `nixos-update`. PATH_add python3 -PATH_add nixos-rebuild-ng +PATH_add nixos-rebuild set -x cd /etc/nixos @@ -36,6 +36,6 @@ sudo git fetch --all --prune sudo git switch "$branch" sudo git pull --rebase -PYTHONNOUSERSITE='true' sudo --preserve-env=PATH --preserve-env=PYTHONNOUSERSITE ".nixos-rebuild-ng-wrapped" --no-reexec boot +PYTHONNOUSERSITE='true' sudo --preserve-env=PATH --preserve-env=PYTHONNOUSERSITE ".nixos-rebuild-wrapped" --no-reexec boot sudo reboot diff --git a/scripts/update_hosts.sh b/scripts/update_hosts.sh index 505f061..cc459ed 100755 --- a/scripts/update_hosts.sh +++ b/scripts/update_hosts.sh @@ -10,10 +10,8 @@ branch="${3-main}" for host in $hosts; do echo "Updating '$user@$host.vhack.eu' ..." - new_system="$(nix build ".#nixosConfigurations.$host.config.system.build.toplevel" --no-link --print-out-paths)" - printf "Copying closure ..\n" - nix-copy-closure "$user@$host.vhack.eu" "$new_system" + nix copy --substitute-on-destination --to "ssh://$user@$host.vhack.eu" ".#nixosConfigurations.$host.config.system.build.toplevel" printf "Deploying remote side script ..\n" scp "$base_dir/scripts/update_hosts.remote" "$user@$host.vhack.eu:update_host.remote" @@ -21,4 +19,9 @@ for host in $hosts; do printf "Executing remote side script ..\n" ssh -t "$user@$host.vhack.eu" "chmod +x update_host.remote; ./update_host.remote '$branch'" done + +# Give the servers some time to reboot +sleep 5 +ping_hosts.sh + # vim: ft=sh |
