2020-08-13 20:54:51 +01:00
|
|
|
#! @runtimeShell@ -e
|
2010-10-21 23:50:12 +01:00
|
|
|
|
|
|
|
# Shows the usage of this command to the user
|
|
|
|
|
2013-10-11 13:12:36 +01:00
|
|
|
showUsage() {
|
|
|
|
exec man nixos-build-vms
|
|
|
|
exit 1
|
2010-10-21 23:50:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse valid argument options
|
|
|
|
|
2019-02-03 11:48:40 +00:00
|
|
|
nixBuildArgs=()
|
|
|
|
networkExpr=
|
2010-10-21 23:50:12 +01:00
|
|
|
|
2019-02-03 11:48:40 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2010-10-21 23:50:12 +01:00
|
|
|
case "$1" in
|
2019-02-03 11:48:40 +00:00
|
|
|
--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)"
|
|
|
|
;;
|
2010-10-21 23:50:12 +01:00
|
|
|
esac
|
2019-02-03 11:48:40 +00:00
|
|
|
|
2010-10-21 23:50:12 +01:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2019-02-03 11:48:40 +00:00
|
|
|
if [ -z "$networkExpr" ]
|
2010-10-21 23:50:12 +01:00
|
|
|
then
|
2010-12-06 22:02:37 +00:00
|
|
|
echo "ERROR: A network expression must be specified!" >&2
|
|
|
|
exit 1
|
2010-10-21 23:50:12 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Build a network of VMs
|
2015-08-05 14:52:12 +01:00
|
|
|
nix-build '<nixpkgs/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix>' \
|
2019-02-03 11:48:40 +00:00
|
|
|
--argstr networkExpr $networkExpr "${nixBuildArgs[@]}"
|