1 { pkgs, lib, config, hostName, private, ... }:
3 domain = "sourcephile.fr";
5 wg = config.networking.wireguard.interfaces.${iface};
7 publicKey = "tE4fzqDrr7BgfOo9tWgGnpu3v0JRDEUZbJnm9e2F/GA=";
8 allowedIPs = [ "192.168.42.3/32" ];
12 publicKey = "XbTEP2X71LBTjmdmySdiOpQJ+uIomcXvg1aiQGUtWBI=";
13 endpoint = "mermet.${domain}:43642";
14 endpointsUpdater.enable = true;
15 allowedIPs = [ "192.168.42.1/32" ];
16 persistentKeepalive = 25;
17 dynamicEndpointRefreshSeconds = 30 * 60;
20 publicKey = "xsFFep3k8z0pXgUOz4aryOF8l/KPBSOd4WQA26BkXy0=";
21 #endpoint = "losurdo.${domain}:43642";
22 allowedIPs = [ "192.168.42.2/32" ];
23 persistentKeepalive = 25;
26 keyToUnitName = lib.replaceChars
27 [ "/" "-" " " "+" "=" ]
28 [ "-" "\\x2d" "\\x20" "\\x2b" "\\x3d" ];
31 networking.firewall.extraCommands = ''
32 ip46tables -A nixos-fw -i ${iface} -p tcp -m tcp --dport 22 -j ACCEPT
33 ip46tables -A nixos-fw -i any -p udp -m udp --dport ${toString wg.listenPort} -j ACCEPT
35 networking.wireguard.interfaces.${iface} = {
36 ips = peer.allowedIPs;
37 # Different from losurdo's listenPort to have them work behind the same NAT.
39 privateKeyFile = "${private}/${hostName}/wireguard/${iface}/privateKey";
40 peers = lib.attrValues peers;
42 networking.hosts = builtins.listToAttrs (lib.concatLists (lib.attrValues (lib.mapAttrs (peerName: peer:
43 map (ip: lib.nameValuePair (lib.removeSuffix "/32" ip) ["${peerName}.wg"]) peer.allowedIPs
49 after = ["wireguard-${iface}.service"];
50 serviceConfig.Restart = "on-failure";
53 services.openssh.listenAddresses = map (ip: {addr=lib.removeSuffix "/32" ip;}) peer.allowedIPs;