nixos: Improve VM networking

This commit is contained in:
2022-05-29 15:22:49 +01:00
parent 00493bf30f
commit baed6f24f6
3 changed files with 73 additions and 56 deletions

View File

@@ -6,7 +6,8 @@
nixos.systems.colony.configuration = { lib, pkgs, config, systems, ... }:
let
inherit (lib) mkMerge;
inherit (builtins) listToAttrs;
inherit (lib) mkIf mkMerge optionals;
wanBDF =
if config.my.build.isDevVM then "00:02.0" else "01:00.0";
@@ -28,32 +29,18 @@
};
in
{
systemd = {
services."vm@estuary" = {
# Depend the interface, networkd wait-online would deadlock...
requires = [ "sys-subsystem-net-devices-base.device" ];
preStart = ''
count=0
while ! ${pkgs.iproute2}/bin/ip link show dev base > /dev/null 2>&1; do
count=$((count+1))
if [ $count -ge 5 ]; then
echo "Timed out waiting for bridge interface"
fi
sleep 0.5
done
'';
};
};
my = {
vms = {
instances = {
estuary = {
uuid = "59f51efb-7e6d-477b-a263-ed9620dbc87b";
networks.base.mac = "52:54:00:ab:f1:52";
networks.base = {
waitOnline = "no-carrier";
mac = "52:54:00:ab:f1:52";
};
drives = {
# TODO: Split into separate LVs
disk = {
disk = mkIf (!config.my.build.isDevVM) {
backend = {
driver = "host_device";
filename = "/dev/ssds/vm-estuary";
@@ -72,10 +59,7 @@
shill = {
uuid = "e34569ec-d24e-446b-aca8-a3b27abc1f9b";
networks.vms.mac = "52:54:00:85:b3:b1";
drives = mkMerge [
(vmLVM "shill" "esp")
(vmLVM "shill" "nix")
(vmLVM "shill" "persist")
drives = mkMerge ([
{
installer = {
backend = {
@@ -89,9 +73,13 @@
bootindex = 1;
};
};
esp.frontendOpts.bootindex = 0;
}
];
] ++ (optionals (!config.my.build.isDevVM) [
(vmLVM "shill" "esp")
(vmLVM "shill" "nix")
(vmLVM "shill" "persist")
{ esp.frontendOpts.bootindex = 0; }
]));
};
};
};