diff options
author | tdro <tdro@users.noreply.github.com> | 2022-01-09 21:42:23 -0500 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2022-01-09 21:42:23 -0500 |
commit | c8454159ac0989e947a4c3180d45589bc2c620a6 (patch) | |
tree | 591b3dd340cfff3bd1ed4d8fb9d7defeb48b664f /.local | |
parent | 3741b2c30d9ce2887b63b86f56ceeb7bf58236c8 (diff) | |
download | dotfiles-c8454159ac0989e947a4c3180d45589bc2c620a6.tar.gz dotfiles-c8454159ac0989e947a4c3180d45589bc2c620a6.tar.bz2 dotfiles-c8454159ac0989e947a4c3180d45589bc2c620a6.zip |
.local/bin/nixos-test: Dry build multiple files
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/nixos-test | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/.local/bin/nixos-test b/.local/bin/nixos-test index 354f8f6..d5e4cfa 100755 --- a/.local/bin/nixos-test +++ b/.local/bin/nixos-test @@ -8,15 +8,23 @@ printf "nixos-test [FILE]...\n" && exit -[ -f "$1" ] || { printf "Error: File '%s' not found\n" "$1" && exit; } +for configuration in "$@"; do -trap 'mv "$1.bak" "$1"; trap - EXIT; exit' EXIT INT HUP + [ -f "$configuration" ] || { printf "Error: File '%s' not found\n" "$configuration" && exit; } -cp "$1" "$1.bak" + cp "$configuration" "$configuration.bak" -nixfmt "$1" + trap 'for configuration in "$@"; do mv "$configuration.bak" "$configuration"; done; trap - EXIT; exit' EXIT INT HUP -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" + nixfmt "$configuration" -NIXOS_CONFIG=$(realpath "$1") nixos-rebuild --fast --option substituters 'https://cache.nixos.org' dry-build + awk '!s {s=sub("^{$","{ boot.isContainer = true;")}{ print $0 }' "$configuration" | sponge "$configuration" + awk '!s {s=sub("^in {$","in { boot.isContainer = true;")}{ print $0 }' "$configuration" | sponge "$configuration" + + printf '%s ' "$configuration"; + + export NIXPKGS_ALLOW_UNFREE=1 + export NIXOS_CONFIG=$(realpath "$configuration") + nixos-rebuild --fast --option substituters 'https://cache.nixos.org' dry-build + +done; |