2020-08-20 17:08:02 +00:00
|
|
|
#! @runtimeShell@ -e
|
2021-12-06 16:07:01 +00:00
|
|
|
# shellcheck shell=bash
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Shows the usage of this command to the user
|
|
|
|
|
|
|
|
showUsage() {
|
|
|
|
exec man nixos-build-vms
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Parse valid argument options
|
|
|
|
|
|
|
|
nixBuildArgs=()
|
|
|
|
networkExpr=
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--no-out-link)
|
|
|
|
nixBuildArgs+=("--no-out-link")
|
|
|
|
;;
|
|
|
|
--show-trace)
|
|
|
|
nixBuildArgs+=("--show-trace")
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
showUsage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--option)
|
|
|
|
shift
|
|
|
|
nixBuildArgs+=("--option" "$1" "$2"); shift
|
|
|
|
;;
|
|
|
|
*)
|
2021-12-06 16:07:01 +00:00
|
|
|
if [ -n "$networkExpr" ]; then
|
2020-04-24 23:36:52 +00:00
|
|
|
echo "Network expression already set!"
|
|
|
|
showUsage
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-12-06 16:07:01 +00:00
|
|
|
networkExpr="$(readlink -f "$1")"
|
2020-04-24 23:36:52 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$networkExpr" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: A network expression must be specified!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build a network of VMs
|
|
|
|
nix-build '<nixpkgs/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix>' \
|
2021-12-06 16:07:01 +00:00
|
|
|
--argstr networkExpr "$networkExpr" "${nixBuildArgs[@]}"
|