nixos-config/linux/singularity/network.nix

61 lines
1.5 KiB
Nix
Raw Normal View History

2023-10-09 10:44:07 -07:00
{ config, ... }:
2023-11-27 13:19:16 -08:00
let hn = config.networking.hostName; port = config.constants.port; wgi = "wgs"; in {
networking = {
2023-10-09 10:44:07 -07:00
domain = config.constants.domain;
2023-11-14 20:56:38 -08:00
firewall = {
2023-11-27 13:19:16 -08:00
allowedTCPPorts = with port; [ http https xray ];
allowedUDPPorts = with port; [ wireguard-server ];
2023-11-14 20:56:38 -08:00
};
2023-10-09 10:44:07 -07:00
hostId = "2cadb253";
2023-11-14 20:56:38 -08:00
nat = {
enable = true;
externalInterface = "ens18";
2023-11-27 13:19:16 -08:00
internalInterfaces = [ wgi ];
2023-11-14 20:56:38 -08:00
};
nftables.enable = true;
2023-11-27 13:19:16 -08:00
wireguard.interfaces.${wgi} = {
2023-11-14 20:56:38 -08:00
ips = [ "10.32.54.76/24" ];
2023-11-27 13:19:16 -08:00
listenPort = port.wireguard-server;
2023-11-14 20:56:38 -08:00
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;
};
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
};
}