540a1dfd76
build-time uses can mostly be replaced with interface.name for runtime uses, switch to $(output ${interface} name)
27 lines
707 B
Nix
27 lines
707 B
Nix
{
|
|
liminix
|
|
, ifwait
|
|
, lib
|
|
}:
|
|
{ members, ifname } :
|
|
let
|
|
inherit (liminix.networking) interface;
|
|
inherit (liminix.services) bundle oneshot;
|
|
inherit (lib) mkOption types;
|
|
primary = interface {
|
|
device = ifname;
|
|
type = "bridge";
|
|
};
|
|
addif = member :
|
|
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";
|
|
dependencies = [ primary member ];
|
|
};
|
|
|
|
in bundle {
|
|
name = "bridge-${primary.name}-members";
|
|
contents = [ primary ] ++ map addif members;
|
|
}
|