28 lines
878 B
Nix
28 lines
878 B
Nix
{ config, lib, modulesPath, numbers, ... }:
|
|
with lib;
|
|
|
|
let
|
|
makeNic = { matchMac, iface, media, ... }:
|
|
# because of the bridge logic, br=iface _and_ internal-iface=iface
|
|
if media != "eth" then [] else [ "-nic bridge,id=${iface},br=${iface},model=virtio,mac=${matchMac}" ];
|
|
makeNicFromHostIface = host: iface: makeNic (numbers.api.hostIface host iface);
|
|
makeNics = host: concatMap (makeNicFromHostIface 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"
|
|
./server.nix
|
|
];
|
|
|
|
config = {
|
|
virtualisation.graphics = false;
|
|
virtualisation.qemu.networkingOptions = makeQemuNetworkingOptions config.networking.hostName;
|
|
};
|
|
}
|