nixos: add routeToNics to vbox guests
This commit is contained in:
parent
040ca60a5a
commit
8354070b48
|
@ -22,6 +22,15 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
routeToNics = lib.mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ "eth0" ];
|
||||
example = [ "eth0" "br0" ];
|
||||
description = ''
|
||||
Grant access to these Nic interfaces.
|
||||
'';
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
description = ''
|
||||
A specification of the desired configuration of this
|
||||
|
@ -88,6 +97,8 @@ in {
|
|||
|
||||
in {
|
||||
|
||||
inherit (cfg) routeToNics;
|
||||
|
||||
inputs = with pkgs.genodePackages; [ libiconv vbox5 vfs_pipe ];
|
||||
|
||||
coreROMs = [ "platform_info" ];
|
||||
|
@ -99,6 +110,7 @@ in {
|
|||
, bootPkg = "${boot.storeRoot}"
|
||||
, bootUuid = ${boot.uuid}
|
||||
, memorySize = ${toString cfg.memorySize}
|
||||
, nicLabels = ${builtins.toJSON cfg.routeToNics} : List Text
|
||||
, vmName = "${vmName}"
|
||||
}
|
||||
'';
|
||||
|
|
|
@ -25,6 +25,7 @@ let Params
|
|||
, bootUuid : Text
|
||||
, bootFormat : BootFormat
|
||||
, memorySize : Natural
|
||||
, nicLabels : List Text
|
||||
, vmName : Text
|
||||
}
|
||||
|
||||
|
@ -86,6 +87,36 @@ let toVbox
|
|||
]
|
||||
}
|
||||
|
||||
let network =
|
||||
XML.element
|
||||
{ name = "Network"
|
||||
, attributes = XML.emptyAttributes
|
||||
, content =
|
||||
Prelude.List.map
|
||||
{ index : Natural, value : Text }
|
||||
XML.Type
|
||||
( λ(label : { index : Natural, value : Text }) →
|
||||
let index = Natural/show label.index
|
||||
|
||||
in { name = "Adapter"
|
||||
, attributes = toMap
|
||||
{ slot = index
|
||||
, enabled = "true"
|
||||
, MACAddress = "0800271D790${index}"
|
||||
, cable = "true"
|
||||
, type = "82540EM"
|
||||
}
|
||||
, content =
|
||||
[ XML.leaf
|
||||
{ name = "BridgedInterface"
|
||||
, attributes = XML.emptyAttributes
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
(Prelude.List.indexed Text params.nicLabels)
|
||||
}
|
||||
|
||||
in ''
|
||||
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.14-freebsd">
|
||||
<Machine uuid="{37ab43a5-38d8-4491-93f5-5b0b077f5c32}" name="${params.vmName}" OSType="Linux26_64" snapshotFolder="Snapshots" lastStateChange="2018-01-23T18:40:00Z">
|
||||
|
@ -110,11 +141,7 @@ let toVbox
|
|||
<USB>
|
||||
<Controllers/>
|
||||
</USB>
|
||||
<Network>
|
||||
<Adapter slot="0" enabled="true" MACAddress="0800271D7901" cable="true" type="82540EM">
|
||||
<BridgedInterface/>
|
||||
</Adapter>
|
||||
</Network>
|
||||
${network}
|
||||
<UART>
|
||||
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
|
||||
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
|
||||
|
|
Loading…
Reference in New Issue