Do not restrict VMs to a single config
Also "allows" full-system build without install.
This commit is contained in:
parent
3806e023f6
commit
224f769324
8 changed files with 80 additions and 17 deletions
66
build_os.sh
Executable file
66
build_os.sh
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash
|
||||
#! nix-shell -p bash nix-output-monitor
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# Parse arguments
|
||||
function help {
|
||||
echo "Usage: $0 [-h|-v|-b] profile"
|
||||
echo
|
||||
echo "Arguments:"
|
||||
echo " profile: OS/disk profile to use"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h: Display this help message."
|
||||
echo " -v: Build a virtual machine."
|
||||
echo " -b: Build a virtual machine with boot loader."
|
||||
}
|
||||
|
||||
attr=system
|
||||
while getopts "hvb" OPTION
|
||||
do
|
||||
case "$OPTION" in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
attr=vm
|
||||
;;
|
||||
b)
|
||||
attr=vmWithBootLoader
|
||||
;;
|
||||
?)
|
||||
help
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND -1))"
|
||||
|
||||
if [ "$#" -ne 1 ]
|
||||
then
|
||||
help
|
||||
exit 2
|
||||
fi
|
||||
profile="$1"
|
||||
|
||||
profile_dir="${SCRIPT_DIR}/${profile}"
|
||||
if [ ! -d "$profile_dir" ]
|
||||
then
|
||||
echo "Profile not found."
|
||||
fi
|
||||
|
||||
nixos_config="${profile_dir}/os.nix"
|
||||
if [ ! -f "$nixos_config" ]
|
||||
then
|
||||
echo "NixOS configuration not found."
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
nom-build '<nixpkgs/nixos>' -I "nixos-config=${nixos_config}" -A "$attr" -o "${profile_dir}/${attr}"
|
||||
|
||||
echo
|
Loading…
Add table
Add a link
Reference in a new issue