1 { pkgs, lib, config, hosts, hostName, wireguard, ... }:
3 inherit (config.security.gnupg) secrets;
5 wg = config.networking.wireguard.interfaces.${iface};
9 ../../../networking/wireguard/wg-intra.nix
12 networking.wireguard.interfaces.${iface} = {
13 privateKeyFile = secrets."wireguard/${iface}/privateKey".path;
15 security.gnupg.secrets."wireguard/${iface}/privateKey" = {};
16 systemd.services."wireguard-${iface}" = {
17 after = [ secrets."wireguard/${iface}/privateKey".service ];
18 requires = [ secrets."wireguard/${iface}/privateKey".service ];
20 networking.nftables.ruleset = ''
21 # Allow peers to initiate connection for ${iface}
22 add rule inet filter net2fw udp dport ${toString wg.listenPort} counter accept comment "${iface}"
24 # Hook ${iface} into relevant chains
25 add rule inet filter input iifname "${iface}" jump intra2fw
26 add rule inet filter input iifname "${iface}" log level warn prefix "intra2fw: " counter drop
27 add rule inet filter output oifname "${iface}" jump fw2intra
28 add rule inet filter output oifname "${iface}" log level warn prefix "fw2intra: " counter drop
30 # ${iface} firewalling
31 add rule inet filter fw2intra counter accept
32 add rule inet filter intra2fw tcp dport ${toString wg.peersAnnouncing.listenPort} counter accept comment "WireGuard peers announcing"
33 add rule inet filter intra2fw ip saddr 192.168.42.2 counter accept comment "losurdo"