diff options
author | Azat Bahawi <azat@bahawi.net> | 2024-05-02 03:17:48 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2024-05-02 03:17:48 +0300 |
commit | 9b3ebd974bde5c8ebe1f8c8f049f7ee2c6462655 (patch) | |
tree | 408194f6f761872df938888ebc4ce46244168618 /modules | |
parent | 2024-05-01 (diff) |
2024-05-02
Diffstat (limited to 'modules')
-rw-r--r-- | modules/default.nix | 4 | ||||
-rw-r--r-- | modules/wireguard.nix | 23 |
2 files changed, 26 insertions, 1 deletions
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); + }; }) ]; } |