forked from DGNum/liminix
1d0fc24111
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
36 lines
1,017 B
Nix
36 lines
1,017 B
Nix
{
|
|
liminix
|
|
, ifwait
|
|
, lib
|
|
, svc
|
|
}:
|
|
{ members, primary } :
|
|
|
|
let
|
|
inherit (liminix.networking) interface;
|
|
inherit (liminix.services) bundle oneshot;
|
|
inherit (lib) mkOption types;
|
|
addif = member :
|
|
# how do we get sight of services from here? maybe we need to
|
|
# implement ifwait as a regualr derivation instead of a
|
|
# servicedefinition
|
|
svc.ifwait.build {
|
|
state = "running";
|
|
interface = member;
|
|
dependencies = [ primary member ];
|
|
service = oneshot {
|
|
name = "${primary.name}.member.${member.name}";
|
|
up = ''
|
|
echo "attaching $(output ${member} ifname) to $(output ${primary} ifname) bridge"
|
|
ip link set dev $(output ${member} ifname) master $(output ${primary} ifname)
|
|
'';
|
|
down = ''
|
|
echo "detaching $(output ${member} ifname) from any bridge"
|
|
ip link set dev $(output ${member} ifname) nomaster
|
|
'';
|
|
};
|
|
};
|
|
in bundle {
|
|
name = "${primary.name}.members";
|
|
contents = map addif members;
|
|
}
|