add nics for eths to vms from numbers
This commit is contained in:
parent
e8b4512af3
commit
97a0c9035f
|
@ -1,6 +1,22 @@
|
|||
{ lib, modulesPath, ... }:
|
||||
{ lib, modulesPath, numbers, ... }:
|
||||
with lib;
|
||||
|
||||
let
|
||||
makeNic = host: iface:
|
||||
let { matchMac, iface, media, ... } = numbers.api.hostIface host iface;
|
||||
in
|
||||
if media != "eth" then [] else
|
||||
[
|
||||
"-nic bridge,id=${iface},br=${iface},model=virtio,mac=${matchMac}"
|
||||
];
|
||||
makeNics = host: concatMap (makeNic host) (numbers.api.hostIfaces host);
|
||||
makeQemuNetworkingOptions = host:
|
||||
(makeNics host) ++ [
|
||||
"-net nic,netdev=user.0,model=virtio"
|
||||
"-netdev user,id=user.0,\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}"
|
||||
];
|
||||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/virtualisation/qemu-vm.nix"
|
||||
|
@ -9,5 +25,6 @@ with lib;
|
|||
|
||||
config = {
|
||||
virtualisation.graphics = false;
|
||||
virtualisation.qemu.networkingOptions = makeQemuNetworkingOptions config.networking.hostName;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user