Add rollback on failure
This commit is contained in:
parent
e19bc8eddb
commit
9a5f573be1
2 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
# nix configuration
|
# nix configuration
|
||||||
|
|
||||||
Use at your own risk.
|
Use at your own risk.
|
||||||
|
|
||||||
|
## Deploying
|
||||||
|
|
||||||
|
The `./deploy` script generates a NixOS configuration that pins the current git `HEAD` of this project and copies the resulting `configuration.nix` to the destionation host. Then it tests the new confiurations and rolls back if it fails.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
- Use `nix-copy-closure`?
|
||||||
|
|
2
deploy
2
deploy
|
@ -22,7 +22,7 @@ host="${1}"
|
||||||
rev="$(git rev-parse HEAD)"
|
rev="$(git rev-parse HEAD)"
|
||||||
sha256=$(hash "$rev")
|
sha256=$(hash "$rev")
|
||||||
|
|
||||||
cat <<EOF | ssh "${host}".dadada.li 'sudo nix-shell -p tmux --run "cat - > /etc/nixos/configuration.nix && tmux new -d \"nixos-rebuild switch |& tee /var/log/dadada-deploy.log\""'
|
cat <<EOF | ssh "${host}".dadada.li 'sudo cat - > /etc/nixos/configuration.nix && (nixos-rebuild test && nixos-rebuild switch) || (nixos-rebuild switch --rollback && exit 1)'
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
host = "$host";
|
host = "$host";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue