summaryrefslogtreecommitdiffstats
path: root/bin/ssh-deploy
blob: fe50677df23b0d874bcda42cf0ae182981784b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/sh
# ssh-deploy : nixos-config x [user@]hostname -> ()
set -xeuf

main=$1
target=$2
nixpkgs_dir=/var/nixpkgs # TODO make configurable

git_url=$(nixpkgs-url $main)
git_rev=$(nixpkgs-rev $main)

if [ "$git_url" = '' ] || [ "$git_rev" = '' ]; then
  echo "specify nixpkgs.url and nixpkgs.rev in $main !"
  exit 23
fi

filter=$(make-rsync-filter "$main")

echo "$filter" \
  | rsync -f '. -' -zvrlptD --delete-excluded ./ "$target":/etc/nixos/

ssh-fetch-git "$target" "$nixpkgs_dir" "$git_url" "$git_rev"
ssh "$target" nixos-rebuild switch \
  -I nixos-config=/etc/nixos/"$main" \
  -I nixpkgs="$nixpkgs_dir" \
  -I secrets=/etc/nixos/secrets \