diff options
author | tdro <tdro@users.noreply.github.com> | 2021-11-15 08:58:09 -0500 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2021-11-15 08:58:09 -0500 |
commit | 2d9e70274d1832b6c65430ca26b5055a4cb78527 (patch) | |
tree | 14d6c6ef93850e4f43746c5334fdfcd5c276520e | |
parent | 401a0d9f8860c7366e06521eb47b686b1290119d (diff) | |
download | dotfiles-2d9e70274d1832b6c65430ca26b5055a4cb78527.tar.gz dotfiles-2d9e70274d1832b6c65430ca26b5055a4cb78527.tar.bz2 dotfiles-2d9e70274d1832b6c65430ca26b5055a4cb78527.zip |
.local/bin/nixos-test: Trap original file
-rwxr-xr-x | .local/bin/nixos-test | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/.local/bin/nixos-test b/.local/bin/nixos-test index 11f43e7..980fddb 100755 --- a/.local/bin/nixos-test +++ b/.local/bin/nixos-test @@ -11,6 +11,8 @@ set -eu [ -f "$1" ] || { printf "Error: File '%s' not found\n" "$1" && exit; } +trap 'mv "$1.bak" "$1"; trap - EXIT; exit' EXIT INT HUP + cp "$1" "$1.bak" nixfmt "$1" @@ -18,6 +20,4 @@ nixfmt "$1" awk '!s {s=sub("^{$","{ boot.isContainer = true;")}{ print $0 }' "$1" | sponge "$1" awk '!s {s=sub("^in {$","in { boot.isContainer = true;")}{ print $0 }' "$1" | sponge "$1" -NIXOS_CONFIG=$(realpath "$1") nixos-rebuild --fast dry-build || true - -mv "$1.bak" "$1" +NIXOS_CONFIG=$(realpath "$1") nixos-rebuild --fast dry-build |