nixos/proxmox-image: add cloud init disk and use cloud-init by default

This commit is contained in:
illustris 2024-04-27 23:34:50 +05:30
parent b90b63db92
commit fe35866a2e
No known key found for this signature in database
GPG Key ID: 56C8FC0B899FEFA3

View File

@ -158,6 +158,31 @@ with lib;
any specific VMID.
'';
};
cloudInit = {
enable = mkOption {
type = types.bool;
default = true;
description = ''
Whether the VM should accept cloud init configurations from PVE.
'';
};
defaultStorage = mkOption {
default = "local-lvm";
example = "tank";
type = types.str;
description = ''
Default storage name for cloud init drive.
'';
};
device = mkOption {
default = "ide2";
example = "scsi0";
type = types.str;
description = ''
Bus/device to which the cloud init drive is attached.
'';
};
};
};
config = let
@ -282,6 +307,20 @@ with lib;
fsType = "vfat";
};
services.qemuGuest.enable = lib.mkDefault true;
networking = mkIf cfg.cloudInit.enable {
hostName = mkForce "";
useDHCP = false;
};
services = {
cloud-init = mkIf cfg.cloudInit.enable {
enable = true;
network.enable = true;
};
sshd.enable = mkDefault true;
qemuGuest.enable = true;
};
proxmox.qemuExtraConf.${cfg.cloudInit.device} = "${cfg.cloudInit.defaultStorage}:vm-9999-cloudinit,media=cdrom";
};
}