diff --git a/nixos/doc/manual/man-nixos-build-vms.xml b/nixos/doc/manual/man-nixos-build-vms.xml index 87e4f3dae869..7d6e04e0dd90 100644 --- a/nixos/doc/manual/man-nixos-build-vms.xml +++ b/nixos/doc/manual/man-nixos-build-vms.xml @@ -24,8 +24,14 @@ - - + + + + + name + value + + network.nix @@ -115,6 +121,18 @@ + + + name value + + + Set the Nix configuration option + name to value. + This overrides settings in the Nix configuration file (see + nix.conf5). + + + diff --git a/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh b/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh index 4e981c074a57..25106733087e 100644 --- a/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh +++ b/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh @@ -9,49 +9,44 @@ showUsage() { # Parse valid argument options -PARAMS=`getopt -n $0 -o h -l no-out-link,show-trace,help -- "$@"` +nixBuildArgs=() +networkExpr= -if [ $? != 0 ] -then - showUsage - exit 1 -fi - -eval set -- "$PARAMS" - -# Evaluate valid options - -while [ "$1" != "--" ] -do +while [ $# -gt 0 ]; do case "$1" in - --no-out-link) - noOutLinkArg="--no-out-link" - ;; - --show-trace) - showTraceArg="--show-trace" - ;; - -h|--help) - showUsage - exit 0 - ;; + --no-out-link) + nixBuildArgs+=("--no-out-link") + ;; + --show-trace) + nixBuildArgs+=("--show-trace") + ;; + -h|--help) + showUsage + exit 0 + ;; + --option) + shift + nixBuildArgs+=("--option" "$1" "$2"); shift + ;; + *) + if [ ! -z "$networkExpr" ]; then + echo "Network expression already set!" + showUsage + exit 1 + fi + networkExpr="$(readlink -f $1)" + ;; esac - + shift done -shift - -# Validate the given options - -if [ "$1" = "" ] +if [ -z "$networkExpr" ] then echo "ERROR: A network expression must be specified!" >&2 exit 1 -else - networkExpr=$(readlink -f $1) fi # Build a network of VMs - nix-build '' \ - --argstr networkExpr $networkExpr $noOutLinkArg $showTraceArg + --argstr networkExpr $networkExpr "${nixBuildArgs[@]}"