From 9b3ebd974bde5c8ebe1f8c8f049f7ee2c6462655 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Thu, 2 May 2024 03:17:48 +0300 Subject: 2024-05-02 --- modules/default.nix | 4 +++- modules/wireguard.nix | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/default.nix b/modules/default.nix index 9ed1029..e41e09b 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,6 @@ -lib: with lib; { +{ lib, ... }: +with lib; +{ nixfiles = { ... }: { diff --git a/modules/wireguard.nix b/modules/wireguard.nix index f645a90..6e5bdbc 100644 --- a/modules/wireguard.nix +++ b/modules/wireguard.nix @@ -9,6 +9,7 @@ with lib; let cfg = config.nixfiles.modules.wireguard; + inherit (config.lib.topology) mkConnection; in { options.nixfiles.modules.wireguard = { @@ -112,6 +113,13 @@ in secrets."wireguard-private-key-${this.hostname}".file = "${inputs.self}/secrets/wireguard-private-key-${this.hostname}"; networking.firewall.trustedInterfaces = [ cfg.interface ]; + + topology = with cfg; { + nodes.${this.hostname}.interfaces.${interface} = { + network = interface; + icon = "interfaces.wireguard"; + }; + }; }) (mkIf cfg.client.enable { networking.wg-quick.interfaces.${cfg.interface} = mkMerge [ @@ -210,6 +218,21 @@ in withRemoteIp = true; port = 9586; }; + + topology = with cfg; { + networks = { + ${interface} = { + name = interface; + cidrv4 = ipv4.subnet; + cidrv6 = ipv6.subnet; + icon = "interfaces.wireguard"; + }; + }; + + nodes.${this.hostname}.interfaces.${interface}.physicalConnections = mapAttrsToList ( + name: _: (mkConnection name interface) + ) (filterAttrs (n: v: !v.isOther && n != this.hostname && hasAttr "wireguard" v) my.configurations); + }; }) ]; } -- cgit 1.4.1