1
0
Fork 0
nixfiles/deploy.sh

33 lines
584 B
Bash
Raw Normal View History

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 \
2021-12-07 19:18:01 +01: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}