Revert "Prevent stupid mistakes"

This reverts commit 3aed3990a5.
This commit is contained in:
Astro 2022-01-07 00:00:10 +01:00
parent 36f9213db7
commit 08f8dcf88e
1 changed files with 50 additions and 0 deletions

50
deploy-flake.sh Executable file
View File

@ -0,0 +1,50 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p rsync
# shellcheck shell=bash
set -eou pipefail
function show_help() {
echo "Usage:"
echo "$0 [--build-local] <host.hq.c3d2.de>"
echo "--help Show this help."
echo "--build-local Build config locally and copy it to the target system via nix copy"
exit 1
}
if [[ $# == 0 ]]; then
show_help
fi
while [[ $# -gt 0 ]]; do
case "${1:-}" in
"" | "-h" | "--help")
show_help
;;
"--build-local")
build_local=true
;;
*)
# strip hostname and user
host=$1
target=${1//.hq.c3d2.de/}
target=${target//.c3d2.de/}
;;
esac
shift
done
if [[ -v build_local ]]; then
nix --experimental-features 'nix-command flakes' -Lv build ".#nixosConfigurations.$target.config.system.build.toplevel"
store_path=$(readlink -f result)
nix --experimental-features 'nix-command flakes' copy --to ssh://root@"$host" -v "$store_path"
ssh root@"$host" "$store_path/bin/switch-to-configuration" switch
else
hostname=$(echo "$target" | cut -d . -f 1)
rsync -az "$(dirname "$0")" root@"$target":nix-config
echo "$hostname> nixos-rebuild switch"
exec ssh root@"$target" "nixos-rebuild --flake ./nix-config#$hostname switch"
fi