@@ -46,6 +46,8 @@ Options:
46
46
URL of the source Nix store to copy the nixos and disko closure from
47
47
* --build-on-remote
48
48
build the closure on the remote machine instead of locally and copy-closuring it
49
+ * --vm-test
50
+ build the system and test the disk configuration inside a VM without installing it to the target.
49
51
USAGE
50
52
}
51
53
@@ -155,7 +157,9 @@ while [[ $# -gt 0 ]]; do
155
157
--build-on-remote)
156
158
build_on_remote=y
157
159
;;
158
-
160
+ --vm-test)
161
+ vm_test=y
162
+ ;;
159
163
* )
160
164
if [[ -z ${ssh_connection-} ]]; then
161
165
ssh_connection=" $1 "
@@ -198,17 +202,19 @@ nix_build() {
198
202
" $@ "
199
203
}
200
204
201
- if [[ -z ${ssh_connection-} ]]; then
202
- abort " ssh-host must be set"
203
- fi
205
+ if [[ -z ${vm_test-} ]]; then
206
+ if [[ -z ${ssh_connection-} ]]; then
207
+ abort " ssh-host must be set"
208
+ fi
204
209
205
- # we generate a temporary ssh keypair that we can use during nixos-anywhere
206
- ssh_key_dir=$( mktemp -d)
207
- trap ' rm -rf "$ssh_key_dir"' EXIT
208
- mkdir -p " $ssh_key_dir "
209
- # ssh-copy-id requires this directory
210
- mkdir -p " $HOME /.ssh/"
211
- ssh-keygen -t ed25519 -f " $ssh_key_dir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
210
+ # we generate a temporary ssh keypair that we can use during nixos-anywhere
211
+ ssh_key_dir=$( mktemp -d)
212
+ trap ' rm -rf "$ssh_key_dir"' EXIT
213
+ mkdir -p " $ssh_key_dir "
214
+ # ssh-copy-id requires this directory
215
+ mkdir -p " $HOME /.ssh/"
216
+ ssh-keygen -t ed25519 -f " $ssh_key_dir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
217
+ fi
212
218
213
219
# parse flake nixos-install style syntax, get the system attr
214
220
if [[ -n ${flake-} ]]; then
@@ -222,6 +228,14 @@ if [[ -n ${flake-} ]]; then
222
228
exit 1
223
229
fi
224
230
if [[ ${build_on_remote-n} == " n" ]]; then
231
+ if [[ -n ${vm_test-} ]]; then
232
+ exec nix build \
233
+ --print-out-paths \
234
+ --no-link \
235
+ -L \
236
+ " ${nix_options[@]} " \
237
+ " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.installTest"
238
+ fi
225
239
disko_script=$( nix_build " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.diskoScript" )
226
240
nixos_system=$( nix_build " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.toplevel" )
227
241
fi
0 commit comments