2023-07-20 12:46:19 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, ifwait
|
|
|
|
, lib
|
|
|
|
}:
|
2023-08-05 15:08:02 +02:00
|
|
|
{ members, primary } :
|
2023-07-20 12:46:19 +02:00
|
|
|
let
|
|
|
|
inherit (liminix.networking) interface;
|
|
|
|
inherit (liminix.services) bundle oneshot;
|
|
|
|
inherit (lib) mkOption types;
|
|
|
|
addif = member :
|
|
|
|
oneshot {
|
|
|
|
name = "add-${member.device}-to-br-${primary.device}";
|
|
|
|
up = "${ifwait}/bin/ifwait ${member.device} running && ip link set dev ${member.device} master ${primary.device}";
|
|
|
|
down = "ip link set dev ${member.device} nomaster";
|
|
|
|
dependencies = [ primary member ];
|
|
|
|
};
|
|
|
|
in bundle {
|
|
|
|
name = "bridge-${primary.device}-members";
|
|
|
|
contents = map addif members;
|
|
|
|
}
|