aboutsummaryrefslogblamecommitdiff
path: root/deploy.sh
blob: 62edcb7f2a151c81fe6cf09448576d7301ffe6d8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                   

                
                    
                                                   




                               







                                           
                                       
 
                                    

                                                             
                                      

                                                                                                             
                                                                                                         
                               
                                                             
    
#!/usr/bin/env bash

cd $(dirname $0)

if [ -z "$@" ]; then
	NIXHOSTLIST=$(ls node | grep -v '\.site\.')
else
	NIXHOSTLIST="$@"
fi

for NIXHOST in $NIXHOSTLIST; do
	NIXHOST=${NIXHOST%.*}

	if [ -z "$SSH_USER" ]; then
		SSH_DEST=$NIXHOST
	else
		SSH_DEST=$SSH_USER@$NIXHOST
	fi

	echo "==== DOING $NIXHOST ===="

	echo "updating Nix channels"
	ssh -F ssh_config $SSH_DEST sudo nix-channel --update

	echo "generating NixOS config"
	cat configuration.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/configuration.nix > /dev/null
	cat node/$NIXHOST.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/node.nix > /dev/null
	cat node/$NIXHOST.site.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/site.nix > /dev/null
	echo "rebuilding NixOS"
	ssh -F ssh_config $SSH_DEST sudo nixos-rebuild switch
done