improve bridge support
instead of a bridge specifiying its members (not ideal if they're not all always up), the member interfaces specify their primary
This commit is contained in:
parent
8194e909ac
commit
3b75cadb20
1 changed files with 20 additions and 9 deletions
|
@ -1,14 +1,25 @@
|
|||
{
|
||||
callPackage
|
||||
, liminix
|
||||
, lib
|
||||
}:
|
||||
let inherit (liminix.services) oneshot longrun;
|
||||
let
|
||||
inherit (liminix.services) oneshot longrun;
|
||||
inherit (lib) concatStringsSep optional;
|
||||
in {
|
||||
interface = { type, device, dependencies ? [] } @ args: oneshot {
|
||||
interface = { type, device, primary ? null, dependencies ? [] } @ args:
|
||||
let ups =
|
||||
[]
|
||||
++ optional (type == "bridge")
|
||||
"ip link add name ${device} type bridge"
|
||||
++ ["ip link set up dev ${device}"]
|
||||
++ optional (primary != null)
|
||||
"ip link set dev ${device} master ${primary.device}";
|
||||
in oneshot {
|
||||
name = "${device}.link";
|
||||
up = "ip link set up dev ${device}";
|
||||
up = lib.concatStringsSep "\n" ups;
|
||||
down = "ip link set down dev ${device}";
|
||||
inherit dependencies;
|
||||
dependencies = dependencies ++ lib.optional (primary != null) primary;
|
||||
} // {
|
||||
inherit device;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue