forked from DGNum/liminix
t #2
2 changed files with 19 additions and 8 deletions
|
@ -43,8 +43,20 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
members = mkOption {
|
members = mkOption {
|
||||||
type = types.listOf liminix.lib.types.interface;
|
type = types.attrsOf (types.submodule ({ ... }: { options = {
|
||||||
description = "interfaces to add to the bridge";
|
member = mkOption {
|
||||||
|
type = liminix.lib.types.interface;
|
||||||
|
description = "interface to add";
|
||||||
|
};
|
||||||
|
|
||||||
|
dependencies = mkOption {
|
||||||
|
type = types.listOf liminix.lib.types.service;
|
||||||
|
default = [];
|
||||||
|
description = "extra dependencies before attaching this interface to the bridge";
|
||||||
|
};
|
||||||
|
}; }));
|
||||||
|
|
||||||
|
description = "set of bridge members";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
{ members, primary } :
|
{ members, primary } :
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (liminix.networking) interface;
|
|
||||||
inherit (liminix.services) bundle oneshot;
|
inherit (liminix.services) bundle oneshot;
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mapAttrs;
|
||||||
addif = member : oneshot {
|
addif = name: { dependencies ? [ ], member }: oneshot {
|
||||||
name = "${primary.name}.member.${member.name}";
|
name = "${primary.name}.member.${name}";
|
||||||
up = ''
|
up = ''
|
||||||
echo "attaching $(output ${member} ifname) to $(output ${primary} ifname) bridge"
|
echo "attaching $(output ${member} ifname) to $(output ${primary} ifname) bridge"
|
||||||
ip link set dev $(output ${member} ifname) master $(output ${primary} ifname)
|
ip link set dev $(output ${member} ifname) master $(output ${primary} ifname)
|
||||||
|
@ -21,9 +20,9 @@ let
|
||||||
ip link set dev $(output ${member} ifname) nomaster
|
ip link set dev $(output ${member} ifname) nomaster
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dependencies = [ primary member ];
|
dependencies = [ primary member ] ++ dependencies;
|
||||||
};
|
};
|
||||||
in bundle {
|
in bundle {
|
||||||
name = "${primary.name}.members";
|
name = "${primary.name}.members";
|
||||||
contents = map addif members;
|
contents = builtins.attrValues (mapAttrs addif members);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue