mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 23:36:17 +01:00
e998f5140f
Also simplified the argument parsing to write all currently supported CLI options into a bash array and pass this to `nix-build`. Also documented `--option` usage in the corresponding manpage.
52 lines
1,016 B
Bash
52 lines
1,016 B
Bash
#! @shell@ -e
|
|
|
|
# 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
|
|
;;
|
|
*)
|
|
if [ ! -z "$networkExpr" ]; then
|
|
echo "Network expression already set!"
|
|
showUsage
|
|
exit 1
|
|
fi
|
|
networkExpr="$(readlink -f $1)"
|
|
;;
|
|
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>' \
|
|
--argstr networkExpr $networkExpr "${nixBuildArgs[@]}"
|