infrastructure/nyx
2021-03-15 17:04:17 +00:00

38 lines
647 B
Bash
Executable file

#!/usr/bin/env bash
set -eu
usage() {
echo example: $0 build samhain boot
}
deploy() {
HOST=$1
if [ $# -gt 2 ]; then
METHOD=$2
else
METHOD="switch"
fi
nix eval --raw deploy.${HOST} -f . | bash -s -- ${METHOD}
}
install() {
HOST=$1
nix build -f . hosts.$HOST.config.system.build.toplevel
CLOSURE=$(readlink result)
nix-store --export $(nix-store -qR ./result) | ssh root@$HOST nix-store --import --store /mnt
ssh root@$HOST nixos-install --system $CLOSURE
}
main() {
if [ $# -lt 2 ]; then
usage
else
CMD=$1
shift
$CMD $@
fi
}
main "$@"