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;
|
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 = [
|
imports = [
|
||||||
"${modulesPath}/virtualisation/qemu-vm.nix"
|
"${modulesPath}/virtualisation/qemu-vm.nix"
|
||||||
|
@ -9,5 +25,6 @@ with lib;
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
virtualisation.graphics = false;
|
virtualisation.graphics = false;
|
||||||
|
virtualisation.qemu.networkingOptions = makeQemuNetworkingOptions config.networking.hostName;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user