#! /bin/sh
#
# nixos-deploy system_name target
#
set -euf

system_name=$1
target=$2

system=$(nixos-build "$system_name")

nix-copy-closure --gzip --to "$target" "$system"

copy-secrets "$system_name" "$target"

ssh ${NIX_SSHOPTS-} "$target" "$system/bin/switch-to-configuration" switch