#!/bin/sh -eu # nix-shell -i dash -p dash gawk moreutils nixos-rebuild nixfmt { [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ] || [ "$#" = 0 ]; } && printf "nixos-test [FILE]...\n" && exit [ -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" 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