From ebcdbf76bcb41b3fd8ba5198ca9b61e33c5e9feb Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Thu, 5 Sep 2024 14:27:47 +0200 Subject: [PATCH] fix(bridge): members are now granular services They are still part of the bundle, but we can wait on each of them independently now. Signed-off-by: Raito Bezarius --- modules/bridge/default.nix | 16 ++++++++++++++-- modules/bridge/members.nix | 11 +++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/modules/bridge/default.nix b/modules/bridge/default.nix index 4c2911a..3a24d7c 100644 --- a/modules/bridge/default.nix +++ b/modules/bridge/default.nix @@ -43,8 +43,20 @@ in }; members = mkOption { - type = types.listOf liminix.lib.types.interface; - description = "interfaces to add to the bridge"; + type = types.attrsOf (types.submodule ({ ... }: { options = { + 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"; }; }; diff --git a/modules/bridge/members.nix b/modules/bridge/members.nix index 2171eda..78c64e2 100644 --- a/modules/bridge/members.nix +++ b/modules/bridge/members.nix @@ -7,11 +7,10 @@ { members, primary } : let - inherit (liminix.networking) interface; inherit (liminix.services) bundle oneshot; - inherit (lib) mkOption types; - addif = member : oneshot { - name = "${primary.name}.member.${member.name}"; + inherit (lib) mapAttrs; + addif = name: { dependencies ? [ ], member }: oneshot { + name = "${primary.name}.member.${name}"; up = '' echo "attaching $(output ${member} ifname) to $(output ${primary} ifname) bridge" ip link set dev $(output ${member} ifname) master $(output ${primary} ifname) @@ -21,9 +20,9 @@ let ip link set dev $(output ${member} ifname) nomaster ''; - dependencies = [ primary member ]; + dependencies = [ primary member ] ++ dependencies; }; in bundle { name = "${primary.name}.members"; - contents = map addif members; + contents = builtins.attrValues (mapAttrs addif members); }