at 24.11-pre 1.0 kB view raw
1#! @runtimeShell@ -e 2# shellcheck shell=bash 3 4# Shows the usage of this command to the user 5 6showUsage() { 7 exec man nixos-build-vms 8 exit 1 9} 10 11# Parse valid argument options 12 13nixBuildArgs=() 14networkExpr= 15 16while [ $# -gt 0 ]; do 17 case "$1" in 18 --no-out-link) 19 nixBuildArgs+=("--no-out-link") 20 ;; 21 --show-trace) 22 nixBuildArgs+=("--show-trace") 23 ;; 24 -h|--help) 25 showUsage 26 exit 0 27 ;; 28 --option) 29 shift 30 nixBuildArgs+=("--option" "$1" "$2"); shift 31 ;; 32 *) 33 if [ -n "$networkExpr" ]; then 34 echo "Network expression already set!" 35 showUsage 36 exit 1 37 fi 38 networkExpr="$(readlink -f "$1")" 39 ;; 40 esac 41 42 shift 43done 44 45if [ -z "$networkExpr" ] 46then 47 echo "ERROR: A network expression must be specified!" >&2 48 exit 1 49fi 50 51# Build a network of VMs 52nix-build '<nixpkgs/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix>' \ 53 --argstr networkExpr "$networkExpr" "${nixBuildArgs[@]}"