2020-12-06 16:59:11 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
DEPLOY_HOST=$1
|
|
|
|
DEPLOY_ADDRESS=$2
|
2020-12-26 01:51:26 +01:00
|
|
|
DEPLOY_PORT=$3
|
2020-12-06 16:59:11 +01:00
|
|
|
|
2020-12-20 00:05:08 +01:00
|
|
|
if [ -z $DEPLOY_HOST ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cmd=" \
|
2020-12-06 16:59:11 +01:00
|
|
|
nixos-rebuild switch \
|
2022-09-14 19:46:15 +02:00
|
|
|
-I "nixos-config=hosts/${DEPLOY_HOST}/configuration.nix" --show-trace\
|
2020-12-20 00:05:08 +01:00
|
|
|
"
|
|
|
|
|
2020-12-26 01:51:26 +01:00
|
|
|
if [ -z $DEPLOY_ADDRESS ] || [ $DEPLOY_ADDRESS = "-" ]; then
|
2020-12-20 00:05:08 +01:00
|
|
|
DEPLOY_ADDRESS="clerie@${DEPLOY_HOST}.net.clerie.de"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $DEPLOY_ADDRESS != "localhost" ]; then
|
|
|
|
cmd="${cmd} \
|
2020-12-06 18:03:45 +01:00
|
|
|
--target-host ${DEPLOY_ADDRESS} \
|
|
|
|
--build-host localhost \
|
2020-12-20 00:05:08 +01:00
|
|
|
--use-remote-sudo \
|
|
|
|
"
|
|
|
|
fi
|
|
|
|
|
2020-12-26 01:51:26 +01:00
|
|
|
if [ -n "$DEPLOY_PORT" ]; then
|
|
|
|
cmd="NIX_SSHOPTS=\"-p $DEPLOY_PORT\" ${cmd}"
|
|
|
|
fi
|
|
|
|
|
2020-12-20 00:05:08 +01:00
|
|
|
eval ${cmd}
|