blob: af1286fbeeb7aeb5851a8fa0d9547a207b0dab74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/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
|