mirror of
https://github.com/Death916/nixconfig.git
synced 2026-04-10 02:54:39 -07:00
libvirt instead of incus
This commit is contained in:
parent
73462abc63
commit
3dc8dfb5eb
7 changed files with 158 additions and 80 deletions
43
modules/vms/ha-deploy-script.nix
Normal file
43
modules/vms/ha-deploy-script.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.homeassistant-vm;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "deploy-haos" ''
|
||||
set -e
|
||||
IMAGE="${cfg.imagePath}"
|
||||
VM_NAME="homeassistant"
|
||||
BRIDGE="${cfg.bridge}"
|
||||
MEM_MB="${toString cfg.memory}"
|
||||
VCPUS="${toString cfg.vcpus}"
|
||||
|
||||
if [ ! -f "$IMAGE" ]; then
|
||||
echo "Error: HAOS image not found at $IMAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if virsh list --all | grep -q " $VM_NAME "; then
|
||||
echo "VM $VM_NAME already exists"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
virt-install \
|
||||
--name "$VM_NAME" \
|
||||
--memory "$MEM_MB" \
|
||||
--vcpus "$VCPUS" \
|
||||
--import \
|
||||
--disk path="$IMAGE",format=qcow2,bus=virtio \
|
||||
--network bridge="$BRIDGE",model=virtio \
|
||||
--os-variant generic \
|
||||
--graphics none \
|
||||
--noautoconsole \
|
||||
--boot uefi
|
||||
|
||||
echo "Home Assistant VM deployed!"
|
||||
echo "Get IP with: haos ip"
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue