0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

Merge pull request #55121 from Ma27/add-option-support-to-nixos-build-vms

nixos-build-vms: pass `--option` to `nix-build`
This commit is contained in:
Danylo Hlynskyi 2019-04-14 02:57:57 +03:00 committed by GitHub
commit eddb31be99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 35 deletions

View file

@ -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 '<nixpkgs/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix>' \
--argstr networkExpr $networkExpr $noOutLinkArg $showTraceArg
--argstr networkExpr $networkExpr "${nixBuildArgs[@]}"