#!/usr/bin/env bash set -eux DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) HOSTNAME="$1" shift CONFIG="$1" shift # Check preconditions #diff <(ls ../config) <(ls config) # We don't want to deploy if we have the wrong set of config files eval "$(ssh-agent)" ssh-add "$CONFIG/ssh_key" RESULT="$(nix-build --no-out-link -A completeServer.aws.system --argstr hostName "$HOSTNAME" "$@")" nix-copy-closure -v --to root@"$HOSTNAME" --gzip "$RESULT" "$DIR/deploy-config" "ssh" root@"$HOSTNAME" "$CONFIG" ssh root@"$HOSTNAME" bash -x <