Skip to content

Commit 1c048c7

Browse files
Mic92mergify[bot]
authored andcommitted
simplify logic around flake
1 parent d1d2605 commit 1c048c7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/nixos-anywhere.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ nixBuild() {
255255
}
256256

257257
runVmTest() {
258-
if [[ -n ${diskoScript-} ]] && [[ -n ${nixosSystem-} ]]; then
258+
if [[ -z ${flakeAttr-} ]]; then
259259
echo "--vm-test is not supported with --store-paths" >&2
260260
echo "Please use --flake instead or build config.system.build.installTest of your nixos configuration manually" >&2
261261
exit 1
@@ -286,7 +286,6 @@ if [[ -z ${sshConnection-} ]]; then
286286
abort "ssh-host must be set"
287287
fi
288288

289-
# parse flake nixos-install style syntax, get the system attr
290289
if [[ -n ${flake-} ]]; then
291290
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
292291
flake="${BASH_REMATCH[1]}"
@@ -297,9 +296,14 @@ if [[ -n ${flake-} ]]; then
297296
echo 'For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
298297
exit 1
299298
fi
300-
if [[ -n $vmTest ]]; then
301-
runVmTest
302-
fi
299+
fi
300+
301+
if [[ -n ${vmTest-} ]]; then
302+
runVmTest
303+
fi
304+
305+
# parse flake nixos-install style syntax, get the system attr
306+
if [[ -n ${flake-} ]]; then
303307
if [[ ${buildOnRemote} == "n" ]]; then
304308
diskoScript=$(nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript")
305309
nixosSystem=$(nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel")
@@ -309,7 +313,7 @@ elif [[ -n ${diskoScript-} ]] && [[ -n ${nixosSystem-} ]]; then
309313
abort "${diskoScript} and ${nixosSystem} must be existing store-paths"
310314
fi
311315
else
312-
abort "flake must be set"
316+
abort "--flake or --store-paths must be set"
313317
fi
314318

315319
if [[ -n ${SSH_PRIVATE_KEY} ]] && [[ -z ${sshPrivateKeyFile-} ]]; then

0 commit comments

Comments
 (0)