aboutsummaryrefslogtreecommitdiff
path: root/deploy_nixos
blob: c6cc89b6a22682c2708242b9c0f7a8c1c0a87b50 (plain) (blame)
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
27
28
29
30
31
32
#!/usr/bin/env ./sshtool

copy nix/configuration.nix /etc/nixos/configuration.nix
copy nix/deuxfleurs.nix /etc/nixos/deuxfleurs.nix
copy cluster/$CLUSTER/cluster.nix /etc/nixos/cluster.nix
copy cluster/$CLUSTER/node/$NIXHOST.nix /etc/nixos/node.nix
copy cluster/$CLUSTER/node/$NIXHOST.site.nix /etc/nixos/site.nix

cmd mkdir -p /var/lib/wgautomesh
write_pass deuxfleurs/cluster/$CLUSTER/wgautomesh_gossip_secret /var/lib/wgautomesh/gossip_secret
copy nix/wgautomesh.nix /etc/nixos/wgautomesh.nix

if [ "$CLUSTER" = "staging" ]; then
	copy nix/nomad-driver-nix2.nix /etc/nixos/nomad-driver-nix2.nix
fi

if [ "$CLUSTER" = "prod" ]; then
	cmd nixos-rebuild boot
	message "-------------------------------------------------------------------------------------"
	message "NIXOS CHANGES THAT WOULD BE APPLIED UPON SWITCH OR REBOOT:"
	cmd nixos-rebuild dry-activate
	message "-------------------------------------------------------------------------------------"
	message "New NixOS configuration hasn't been applied, to avoid disturbing production services."
	message "Please apply the following procedure to node '$NIXHOST':"
	message "1. Drain node in Nomad so that all jobs are relocated elsewhere"
	message "2. Reboot node manually. You can also take the opportunity to upgrade with:"
	message "         REBOOT_NODES=yes ./upgrade_nixos prod $NIXHOST"
	message "3. Mark node as eligible again in Nomad"
	message "-------------------------------------------------------------------------------------"
else
	cmd nixos-rebuild switch
fi