Files
homelab/modules/containers-terraform-proxmox.nix
T
2026-06-24 15:56:42 +02:00

44 lines
895 B
Nix

{
config,
...
}:
let
cfg = config.my-lxc;
in
{
proxmox_lxc = builtins.mapAttrs (
name: def:
let
c = def.container;
in
lib.mkIf (c.enable) {
hostname = name;
memory = c.memory;
cores = c.cores;
ostemplate = "local:vztmpl/\${var.ostemplate}.tar.xz";
unprivileged = true;
password = "changeme";
features.nesting = true;
target_node = "\${var.pve_node}";
network = {
name = "eth0";
bridge = "vmbr0";
ip = "192.168.1.${name}";
gw = config.globals.gateway;
type = "veth";
};
protection = c.protection;
onboot = c.onboot;
rootfs = {
storage = "local-lvm";
size = c.disk;
};
swap = c.swap;
vmid = config.id.${name};
tags = builtins.strings.join ";" ([ "terraform" ] ++ c.tags);
}
// c.overrides
) cfg;
}