nixos/vms: Add UUID and MAC address options
This commit is contained in:
parent
1eac3c8577
commit
5563d1be46
@ -42,6 +42,12 @@ in
|
|||||||
help = pkgs.agenix.meta.description;
|
help = pkgs.agenix.meta.description;
|
||||||
command = ''exec ${pkgs.agenix}/bin/agenix --identity "$PRJ_ROOT/.keys/dev.key" "$@"'';
|
command = ''exec ${pkgs.agenix}/bin/agenix --identity "$PRJ_ROOT/.keys/dev.key" "$@"'';
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "qemu-genmac";
|
||||||
|
category = "utilities";
|
||||||
|
help = "Generate MAC address suitable for QEMU";
|
||||||
|
command = ''printf "52:54:00:ab:%02x:%02x\n" $((RANDOM%256)) $((RANDOM%256))'';
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "fmt";
|
name = "fmt";
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
};
|
};
|
||||||
vms = {
|
vms = {
|
||||||
instances.test = {
|
instances.test = {
|
||||||
networks.virtual = {};
|
uuid = "59f51efb-7e6d-477b-a263-ed9620dbc87b";
|
||||||
|
networks.virtual.mac = "52:54:00:ab:f1:52";
|
||||||
drives = {
|
drives = {
|
||||||
disk = {
|
disk = {
|
||||||
backend = {
|
backend = {
|
||||||
|
@ -44,6 +44,7 @@ let
|
|||||||
options = {
|
options = {
|
||||||
bridge = mkOpt' str name "Network bridge to connect to.";
|
bridge = mkOpt' str name "Network bridge to connect to.";
|
||||||
model = mkOpt' str "virtio-net" "Device type for network interface.";
|
model = mkOpt' str "virtio-net" "Device type for network interface.";
|
||||||
|
mac = mkOpt' str null "Guest MAC address.";
|
||||||
extraOptions = mkOpt' qemuOpts { } "Extra QEMU options to set for the NIC.";
|
extraOptions = mkOpt' qemuOpts { } "Extra QEMU options to set for the NIC.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -70,6 +71,7 @@ let
|
|||||||
timeout = mkOpt' ints.unsigned 30 "Clean shutdown timeout (in seconds).";
|
timeout = mkOpt' ints.unsigned 30 "Clean shutdown timeout (in seconds).";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uuid = mkOpt' str null "QEMU machine UUID.";
|
||||||
machine = mkOpt' str "q35" "QEMU machine type.";
|
machine = mkOpt' str "q35" "QEMU machine type.";
|
||||||
enableKVM = mkBoolOpt' true "Whether to enable KVM.";
|
enableKVM = mkBoolOpt' true "Whether to enable KVM.";
|
||||||
enableUEFI = mkBoolOpt' true "Whether to enable UEFI.";
|
enableUEFI = mkBoolOpt' true "Whether to enable UEFI.";
|
||||||
@ -92,6 +94,7 @@ let
|
|||||||
i.qemuFlags ++
|
i.qemuFlags ++
|
||||||
[
|
[
|
||||||
"name ${n}"
|
"name ${n}"
|
||||||
|
"uuid ${i.uuid}"
|
||||||
"machine ${i.machine}"
|
"machine ${i.machine}"
|
||||||
"cpu ${i.cpu}"
|
"cpu ${i.cpu}"
|
||||||
"smp cpus=${toString i.smp.cpus},threads=${toString i.smp.threads}"
|
"smp cpus=${toString i.smp.cpus},threads=${toString i.smp.threads}"
|
||||||
@ -113,7 +116,7 @@ let
|
|||||||
(optional i.spice.enable "spice unix=on,addr=/run/vms/${n}/spice.sock,disable-ticketing=on") ++
|
(optional i.spice.enable "spice unix=on,addr=/run/vms/${n}/spice.sock,disable-ticketing=on") ++
|
||||||
(flatten (mapAttrsToList (nn: c: [
|
(flatten (mapAttrsToList (nn: c: [
|
||||||
"netdev bridge,id=${nn},br=${c.bridge}"
|
"netdev bridge,id=${nn},br=${c.bridge}"
|
||||||
("device ${c.model},netdev=${nn}" + (extraQEMUOpts c.extraOptions))
|
("device ${c.model},netdev=${nn},mac=${c.mac}" + (extraQEMUOpts c.extraOptions))
|
||||||
]) i.networks)) ++
|
]) i.networks)) ++
|
||||||
(flatten (mapAttrsToList (dn: c: [
|
(flatten (mapAttrsToList (dn: c: [
|
||||||
"blockdev node-name=${dn}-backend,${c.backend}"
|
"blockdev node-name=${dn}-backend,${c.backend}"
|
||||||
|
Loading…
Reference in New Issue
Block a user