90
90
sshTtyParam=" -T"
91
91
fi
92
92
postKexecSshPort=22
93
+ buildOnRemote=n
93
94
94
95
declare -A diskEncryptionKeys
95
96
declare -a nixCopyOptions
@@ -252,20 +253,46 @@ nixBuild() {
252
253
" $@ "
253
254
}
254
255
255
- if [[ -z ${vmTest-} ]]; then
256
- if [[ -z ${sshConnection-} ]]; then
257
- abort " ssh-host must be set"
256
+ runVmTest () {
257
+ if [[ -n ${diskoScript-} ]] && [[ -n ${nixosSystem-} ]]; then
258
+ echo " --vm-test is not supported with --store-paths" >&2
259
+ echo " Please use --flake instead or build config.system.build.installTest of your nixos configuration manually" >&2
260
+ exit 1
258
261
fi
259
262
260
- # we generate a temporary ssh keypair that we can use during nixos-anywhere
261
- ssh_key_dir=$( mktemp -d)
262
- trap ' rm -rf "$ssh_key_dir"' EXIT
263
- mkdir -p " $ssh_key_dir "
264
- # ssh-copy-id requires this directory
265
- mkdir -p " $HOME /.ssh/"
266
- ssh-keygen -t ed25519 -f " $ssh_key_dir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
263
+ if [[ ${buildOnRemote} == " y" ]]; then
264
+ echo " --vm-test is not supported with --build-on-remote" >&2
265
+ exit 1
266
+ fi
267
+ if [[ -n ${extraFiles-} ]]; then
268
+ echo " --vm-test is not supported with --extra-files" >&2
269
+ exit 1
270
+ fi
271
+ if [[ -n ${diskEncryptionKeys-} ]]; then
272
+ echo " --vm-test is not supported with --disk-encryption-keys" >&2
273
+ exit 1
274
+ fi
275
+ exec nix build \
276
+ --print-out-paths \
277
+ --no-link \
278
+ -L \
279
+ " ${nixOptions[@]} " \
280
+ " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.installTest"
281
+ }
282
+
283
+
284
+ if [[ -z ${sshConnection-} ]]; then
285
+ abort " ssh-host must be set"
267
286
fi
268
287
288
+ # we generate a temporary ssh keypair that we can use during nixos-anywhere
289
+ ssh_key_dir=$( mktemp -d)
290
+ trap ' rm -rf "$ssh_key_dir"' EXIT
291
+ mkdir -p " $ssh_key_dir "
292
+ # ssh-copy-id requires this directory
293
+ mkdir -p " $HOME /.ssh/"
294
+ ssh-keygen -t ed25519 -f " $ssh_key_dir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
295
+
269
296
# parse flake nixos-install style syntax, get the system attr
270
297
if [[ -n ${flake-} ]]; then
271
298
if [[ $flake =~ ^(.* )\# ([^\#\" ]* )$ ]]; then
@@ -277,32 +304,14 @@ if [[ -n ${flake-} ]]; then
277
304
echo ' For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
278
305
exit 1
279
306
fi
280
- if [[ ${buildOnRemote-n} == " n" ]]; then
281
- if [[ -n ${vmTest-} ]]; then
282
- if [[ -n ${extraFiles-} ]]; then
283
- echo " --vm-test is not supported with --extra-files" >&2
284
- exit 1
285
- fi
286
- if [[ -n ${diskEncryptionKeys-} ]]; then
287
- echo " --vm-test is not supported with --disk-encryption-keys" >&2
288
- exit 1
289
- fi
290
- exec nix build \
291
- --print-out-paths \
292
- --no-link \
293
- -L \
294
- " ${nixOptions[@]} " \
295
- " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.installTest"
296
- fi
307
+ if [[ -n $vmTest ]]; then
308
+ runVmTest
309
+ fi
310
+ if [[ ${buildOnRemote} == " n" ]]; then
297
311
diskoScript=$( nixBuild " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.diskoScript" )
298
312
nixosSystem=$( nixBuild " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.toplevel" )
299
313
fi
300
314
elif [[ -n ${diskoScript-} ]] && [[ -n ${nixosSystem-} ]]; then
301
- if [[ -n ${vmTest-} ]]; then
302
- echo " vm-test is not supported with --store-paths" >&2
303
- echo " Please use --flake instead or build config.system.build.installTest of your nixos configuration manually" >&2
304
- exit 1
305
- fi
306
315
if [[ ! -e ${diskoScript} ]] || [[ ! -e ${nixosSystem} ]]; then
307
316
abort " ${diskoScript} and ${nixosSystem} must be existing store-paths"
308
317
fi
@@ -446,7 +455,7 @@ runDisko() {
446
455
done
447
456
if [[ -n ${diskoScript-} ]]; then
448
457
nixCopy --to " ssh://$sshConnection " " $diskoScript "
449
- elif [[ ${buildOnRemote-n } == " y" ]]; then
458
+ elif [[ ${buildOnRemote} == " y" ]]; then
450
459
step Building disko script
451
460
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
452
461
nixCopy --to " ssh-ng://$sshConnection " " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.diskoScript" \
@@ -465,7 +474,7 @@ nixosInstall() {
465
474
if [[ -n ${nixosSystem-} ]]; then
466
475
step Uploading the system closure
467
476
nixCopy --to " ssh://$sshConnection ?remote-store=local?root=/mnt" " $nixosSystem "
468
- elif [[ ${buildOnRemote-n } == " y" ]]; then
477
+ elif [[ ${buildOnRemote} == " y" ]]; then
469
478
step Building the system closure
470
479
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
471
480
nixCopy --to " ssh-ng://$sshConnection ?remote-store=local?root=/mnt" " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.toplevel" \
0 commit comments