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