2018-06-30 19:42:31 +00:00
|
|
|
#!/bin/bash
|
2018-06-30 19:49:12 +00:00
|
|
|
|
|
|
|
APPVM_PATH=$(dirname $(realpath $0))
|
|
|
|
cd ${APPVM_PATH}
|
|
|
|
|
2018-06-30 19:42:31 +00:00
|
|
|
if [[ "$1" == "build" && "$2" != "" ]]; then
|
|
|
|
NIX_PATH=$NIX_PATH:. nix-build '<nixpkgs/nixos>' -A config.system.build.vm -I nixos-config=nix/${2}.nix || exit 1
|
|
|
|
NIX_SYSTEM=$(realpath result/system)
|
|
|
|
mkdir -p bin
|
|
|
|
sed "s;NIX_SYSTEM_PLACEHOLDER;${NIX_SYSTEM};" qemu/qemu.template > bin/appvm.${2}
|
|
|
|
sed -i "s;NAME_PLACEHOLDER;${2};" bin/appvm.${2}
|
2018-06-30 19:51:56 +00:00
|
|
|
sed -i "s;NIX_DISK_IMAGE_PLACEHOLDER;${APPVM_PATH}/qemu/qcow2/${2}.qcow2;" bin/appvm.${2}
|
2018-06-30 19:42:31 +00:00
|
|
|
chmod +x bin/appvm.${2}
|
|
|
|
unlink result
|
|
|
|
else
|
|
|
|
echo "Usage: $0 build APPLICATION"
|
|
|
|
fi
|