dotfiles/hosts/dark-firepit/wireguardInterface.nix

23 lines
450 B
Nix
Raw Normal View History

2022-04-23 03:01:00 +02:00
{ lib, pkgs, config, ... }:
with lib;
let
2022-10-18 19:54:57 +02:00
peerKeys = import ./authorizedKeys.nix;
wgKeys = filter (hasAttr "wg") peerKeys;
2022-04-23 03:01:00 +02:00
in {
ips = [ "10.100.0.1/24" ];
privateKeyFile = "/etc/wg0.keys/wg0";
2022-04-23 03:01:00 +02:00
listenPort = 51820;
2022-10-18 19:54:57 +02:00
peers = genList (n:
let
keychain = elemAt wgKeys n;
ip = "10.100.0.${toString (n+2)}/32";
in {
publicKey = trace "${keychain.hostname}: ${ip}" keychain.wg;
allowedIPs = [ ip ];
}) (length wgKeys);
2022-04-23 03:01:00 +02:00
}