{lib,...}: let build = iface: mac: rest: lib.recursiveUpdate rest { networking.usePredictableInterfaceNames = false; boot.initrd.systemd.enable = true; boot.initrd.services.udev.rules = '' SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \ ADDR{address}=="${mac}", KERNEL="eth*", NAME="${iface}" ''; boot.initrd.systemd.network = { enable = true; links."${iface}" = { linkConfig.Name = iface; matchConfig.PermanentMACAddress = mac; }; wait-online.enable = false; }; systemd.network = { enable = true; links."${iface}" = { linkConfig.Name = iface; matchConfig.PermanentMACAddress = mac; }; networks."${iface}".enable = true; wait-online.anyInterface = true; }; }; in { bridge = br: ip: gateway: iface: mac: build iface mac { systemd.network = { networks = { "${iface}".bridge = [ br ]; "${br}" = { address = [ ip ]; gateway = [ gateway ]; }; }; netdevs = { "${br}" = { netdevConfig = { Name = br; Kind = "bridge"; }; }; }; }; }; dhcp = iface: mac: build iface mac { systemd.network.networks."${iface}" = { matchConfig.Name = iface; DHCP = "yes"; }; networking.interfaces."${iface}".useDHCP = true; }; }