liminix/modules/bridge/primary.nix
Raito Bezarius 21ff11503e fix(bridge): pick up MAC from another interface
This avoids the OPERSTATE unknown when the bridge is brought up but the
members are not ready yet.

This will make OPERSTATE to down, enabling us to wait until we have
brought up completely all the members.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-09-01 17:48:54 +02:00

22 lines
602 B
Nix

{
liminix
, ifwait
, lib
}:
{ ifname, macAddressFromInterface ? null } :
let
inherit (liminix.services) bundle oneshot;
inherit (lib) mkOption types optional;
in oneshot rec {
name = "${ifname}.link";
up = ''
${if macAddressFromInterface == null then
"ip link add name ${ifname} type bridge"
else
"ip link add name ${ifname} address $(output ${macAddressFromInterface} ether) type bridge"}
${liminix.networking.ifup name ifname}
'';
down = "ip link set down dev ${ifname}";
dependencies = optional (macAddressFromInterface != null) macAddressFromInterface;
}