nixos-config/linux/singularity/network.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

2023-10-09 10:44:07 -07:00
{ config, ... }:
2023-11-09 20:24:14 -08:00
let hn = config.networking.hostName; in {
2023-11-14 20:56:38 -08:00
networking = let wg = { interface = "wgs"; port = 45556; }; in {
2023-10-09 10:44:07 -07:00
domain = config.constants.domain;
2023-11-14 20:56:38 -08:00
firewall = {
allowedTCPPorts = [ 80 443 50051 ];
allowedUDPPorts = [ wg.port ];
};
2023-10-09 10:44:07 -07:00
hostId = "2cadb253";
2023-11-14 20:56:38 -08:00
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=";
}
2023-11-14 21:14:36 -08:00
{
allowedIPs = [ "10.32.54.6/32" ];
publicKey = "yR099WK5V11Y6jr5CheXl6SDWPpvUMtvoItlO+JJd24=";
}
2023-11-14 20:56:38 -08:00
];
privateKeyFile = config.sops.secrets."wireguard/${hn}".path;
};
2023-10-09 10:44:07 -07:00
};
2023-11-14 20:56:38 -08:00
services = {
cloudflare-dyndns = {
enable = true;
apiTokenFile = config.sops.secrets."cloudflare/${hn}".path;
domains = builtins.attrNames config.services.caddy.virtualHosts;
2023-10-09 10:44:07 -07:00
};
2023-11-14 20:56:38 -08:00
openssh = {
enable = true;
settings = {
KbdInteractiveAuthentication = false;
PasswordAuthentication = false;
};
hostKeys = [{
comment = "host@${hn}";
path = "/etc/ssh/host";
rounds = 100;
type = "ed25519";
}];
};
resolved.enable = true;
2023-10-09 10:44:07 -07:00
};
2023-11-14 20:56:38 -08:00
sops.secrets = {
"cloudflare/${hn}" = { };
"wireguard/${hn}" = { };
2023-10-09 10:44:07 -07:00
};
}