name = "lxd_provider_fragment"

[[elements]]
border_bottom = true
border_top = true
name = "lxd_header"
title = "🖥️  LXD Container/VM Configuration"
type = "section_header"

[[elements]]
default = "local"
help = "Use local LXD or connect to remote LXD server"
name = "lxd_remote"
nickel_path = ["provider", "lxd_remote"]
options = [
  { value = "local", label = "local - Local LXD server" },
  { value = "remote", label = "remote - Remote LXD server" },
]
prompt = "LXD Remote"
required = true
type = "select"

[[elements]]
help = "Address of remote LXD server (e.g., https://lxd.example.com:8443)"
name = "lxd_remote_address"
nickel_path = ["provider", "lxd_remote_address"]
prompt = "Remote server address (if remote)"
required = false
type = "text"

[[elements]]
help = "Trust password for remote LXD server (will be masked)"
name = "lxd_remote_password"
nickel_path = ["provider", "lxd_remote_password"]
prompt = "Remote server password (if remote)"
required = false
type = "password"

[[elements]]
default = "container"
help = "Run as container (fast, lightweight) or virtual machine (isolated)"
name = "lxd_instance_type"
nickel_path = ["provider", "lxd_instance_type"]
options = [
  { value = "container", label = "Container - Lightweight, shared kernel" },
  { value = "virtual-machine", label = "Virtual Machine - Full VM with own kernel" },
]
prompt = "Instance Type"
required = true
type = "select"

[[elements]]
default = "ubuntu:24.04"
help = "Operating system image for the instance"
name = "lxd_image"
nickel_path = ["provider", "lxd_image"]
options = [
  { value = "ubuntu:24.04", label = "Ubuntu 24.04 LTS (Noble)" },
  { value = "ubuntu:22.04", label = "Ubuntu 22.04 LTS (Jammy)" },
  { value = "ubuntu:20.04", label = "Ubuntu 20.04 LTS (Focal)" },
  { value = "debian:12", label = "Debian 12 (Bookworm)" },
  { value = "debian:11", label = "Debian 11 (Bullseye)" },
  { value = "alpine:3.19", label = "Alpine Linux 3.19 (minimal)" },
  { value = "alpine:3.18", label = "Alpine Linux 3.18" },
  { value = "rockylinux:9", label = "Rocky Linux 9" },
  { value = "rockylinux:8", label = "Rocky Linux 8" },
  { value = "archlinux", label = "Arch Linux (rolling release)" },
]
prompt = "Base Image"
required = true
type = "select"

[[elements]]
help = "Unique name for the LXD instance"
name = "lxd_instance_name"
nickel_path = ["provider", "lxd_instance_name"]
prompt = "Instance name"
required = true
type = "text"

[[elements]]
default = "2"
help = "Number of CPU cores (e.g., 2 or leave empty for unlimited)"
name = "lxd_cpu_limit"
nickel_path = ["provider", "lxd_cpu_limit"]
prompt = "CPU limit (cores)"
required = false
type = "text"

[[elements]]
default = "2GB"
help = "Memory limit (e.g., 2GB, 4GB, or leave empty for unlimited)"
name = "lxd_memory_limit"
nickel_path = ["provider", "lxd_memory_limit"]
prompt = "Memory limit"
required = false
type = "text"

[[elements]]
default = "10GB"
help = "Root disk size (e.g., 10GB, 20GB, or leave empty for default)"
name = "lxd_disk_size"
nickel_path = ["provider", "lxd_disk_size"]
prompt = "Root disk size"
required = false
type = "text"

[[elements]]
default = "default"
help = "Storage pool for the instance root disk"
name = "lxd_storage_pool"
nickel_path = ["provider", "lxd_storage_pool"]
options = [
  { value = "default", label = "default - Default storage pool" },
  { value = "dir", label = "dir - Directory-backed pool" },
  { value = "zfs", label = "zfs - ZFS pool (best performance)" },
  { value = "btrfs", label = "btrfs - Btrfs pool" },
  { value = "lvm", label = "lvm - LVM pool" },
]
prompt = "Storage pool"
required = true
type = "select"

[[elements]]
default = "lxdbr0"
help = "Network configuration for the instance"
name = "lxd_network"
nickel_path = ["provider", "lxd_network"]
options = [
  { value = "lxdbr0", label = "lxdbr0 - Default LXD bridge (NAT)" },
  { value = "host", label = "host - Direct host networking" },
  { value = "macvlan", label = "macvlan - MAC VLAN (bridge to physical)" },
]
prompt = "Network"
required = true
type = "select"

[[elements]]
help = "Assign static IPv4 (e.g., 10.0.0.100) or leave empty for DHCP"
name = "lxd_ipv4_address"
nickel_path = ["provider", "lxd_ipv4_address"]
prompt = "Static IPv4 address (optional)"
required = false
type = "text"

[[elements]]
help = "Assign static IPv6 or leave empty for auto"
name = "lxd_ipv6_address"
nickel_path = ["provider", "lxd_ipv6_address"]
prompt = "Static IPv6 address (optional)"
required = false
type = "text"

[[elements]]
default = "default"
help = "LXD profiles to apply (e.g., default,docker)"
name = "lxd_profiles"
nickel_path = ["provider", "lxd_profiles"]
prompt = "Additional profiles (comma-separated)"
required = false
type = "text"

[[elements]]
default = false
help = "Allow running containers/VMs inside this instance"
name = "lxd_enable_nesting"
nickel_path = ["provider", "lxd_enable_nesting"]
prompt = "Enable nesting (for Docker/LXD inside)?"
type = "confirm"

[[elements]]
default = false
help = "Run container without user namespace isolation (less secure)"
name = "lxd_privileged"
nickel_path = ["provider", "lxd_privileged"]
prompt = "Run as privileged container?"
type = "confirm"

[[elements]]
default = true
help = "Automatically start instance when LXD daemon starts"
name = "lxd_autostart"
nickel_path = ["provider", "lxd_autostart"]
prompt = "Auto-start on boot?"
type = "confirm"

[[elements]]
help = "Path to cloud-init configuration file (leave empty to skip)"
name = "lxd_cloud_init"
nickel_path = ["provider", "lxd_cloud_init"]
prompt = "Cloud-init user data (optional)"
required = false
type = "text"
