diff --git a/nix/lib/config/legacy.nix b/nix/lib/config/legacy.nix index a1e2bea..311cbea 100644 --- a/nix/lib/config/legacy.nix +++ b/nix/lib/config/legacy.nix @@ -121,14 +121,25 @@ in ospf = let - hostPillar = self.lib.saltPillarFor name; - ospfConf = hostPillar.ospf; - in lib.optionalAttrs (hostPillar ? ospf && ospfConf ? stubnets-inet) { + ospfConf = ctPillar.ospf; + in lib.optionalAttrs (ctPillar ? ospf && ospfConf ? stubnets-inet) { stubNets4 = ospfConf.stubnets-inet; - } // lib.optionalAttrs (hostPillar ? ospf && ospfConf ? stubnets-inet6) { + } // lib.optionalAttrs (ctPillar ? ospf && ospfConf ? stubnets-inet6) { stubNets6 = ospfConf.stubnets-inet6; }; + bgp = + if ctPillar ? bgp + then + let + bgpConf = ctPillar.bgp; + in { + inherit (bgpConf) asn; + peers4 = bgpConf.peers-inet; + peers6 = bgpConf.peers-inet6; + } + else null; + forwardPorts = if ctPillar ? port-forwarding then map ({ proto, port, to }: { diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index f898135..41b1ab7 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -221,6 +221,32 @@ let } )); }; + bgp = mkOption { + default = null; + type = with types; nullOr (submodule { + options = bgpOpts; + }); + }; + }; + }; + bgpPeerOpts = { name, ... }: { + options = { + asn = mkOption { + type = types.int; + }; + }; + }; + bgpOpts = { + asn = mkOption { + type = types.int; + }; + peers4 = mkOption { + type = with types; attrsOf (submodule bgpPeerOpts); + default = {}; + }; + peers6 = mkOption { + type = with types; attrsOf (submodule bgpPeerOpts); + default = {}; }; }; in