depot/pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.sh
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

54 lines
1,020 B
Bash

#! @runtimeShell@ -e
# shellcheck shell=bash
# 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 [ -n "$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 @buildVms@ \
--argstr networkExpr "$networkExpr" "${nixBuildArgs[@]}" \
--arg nixpkgs "<nixpkgs>"