nixos-config/linux/singularity/network.nix
2023-11-14 20:56:38 -08:00

60 lines
1.5 KiB
Nix

{ config, ... }:
let hn = config.networking.hostName; in {
networking = let wg = { interface = "wgs"; port = 45556; }; in {
domain = config.constants.domain;
firewall = {
allowedTCPPorts = [ 80 443 50051 ];
allowedUDPPorts = [ wg.port ];
};
hostId = "2cadb253";
nat = {
enable = true;
externalInterface = "ens18";
internalInterfaces = [ wg.interface ];
};
nftables.enable = true;
wireguard.interfaces.${wg.interface} = {
ips = [ "10.32.54.76/24" ];
listenPort = wg.port;
peers = [
{
allowedIPs = [ "10.32.54.2/32" ];
publicKey = "RhS1H8g47EnOhu1F6y3QO6XqxnabGcNNb0BixBuKkDQ=";
}
{
allowedIPs = [ "10.32.54.3/32" ];
publicKey = "1OA03mqu7SxREAum4UabJKD7hf+foPLu1j0E1N5K508=";
}
];
privateKeyFile = config.sops.secrets."wireguard/${hn}".path;
};
};
services = {
cloudflare-dyndns = {
enable = true;
apiTokenFile = config.sops.secrets."cloudflare/${hn}".path;
domains = builtins.attrNames config.services.caddy.virtualHosts;
};
openssh = {
enable = true;
settings = {
KbdInteractiveAuthentication = false;
PasswordAuthentication = false;
};
hostKeys = [{
comment = "host@${hn}";
path = "/etc/ssh/host";
rounds = 100;
type = "ed25519";
}];
};
resolved.enable = true;
};
sops.secrets = {
"cloudflare/${hn}" = { };
"wireguard/${hn}" = { };
};
}