1
0
nixfiles/deploy.sh

33 lines
586 B
Bash
Executable File

#!/usr/bin/env bash
DEPLOY_HOST=$1
DEPLOY_ADDRESS=$2
DEPLOY_PORT=$3
if [ -z $DEPLOY_HOST ]; then
exit 1
fi
cmd=" \
nixos-rebuild switch \
-I "nixos-config=hosts/${DEPLOY_HOST}/configuration.nix" --show-trace\
"
if [ -z $DEPLOY_ADDRESS ] || [ $DEPLOY_ADDRESS = "-" ]; then
DEPLOY_ADDRESS="clerie@${DEPLOY_HOST}.net.clerie.de"
fi
if [ $DEPLOY_ADDRESS != "localhost" ]; then
cmd="${cmd} \
--target-host ${DEPLOY_ADDRESS} \
--build-host localhost \
--use-remote-sudo \
"
fi
if [ -n "$DEPLOY_PORT" ]; then
cmd="NIX_SSHOPTS=\"-p $DEPLOY_PORT\" ${cmd}"
fi
eval ${cmd}