Update port config

This commit is contained in:
Invariantspace 2023-11-27 13:19:16 -08:00
parent f2e2700acb
commit aa79162e2c
6 changed files with 33 additions and 21 deletions

View file

@ -4,28 +4,41 @@
type = types.str; type = types.str;
default = "invariantspace.com"; default = "invariantspace.com";
description = '' description = ''
Store the default domain for all devices. The domain for all devices.
''; '';
}; };
homeDir = mkOption { homeDir = mkOption {
type = types.str; type = types.str;
default = "/home/${config.constants.userName}"; default = "/home/${config.constants.userName}";
description = '' description = ''
The default home directory for the default user. The home directory for the default user.
''; '';
}; };
localhost = mkOption { localhost = mkOption {
type = types.str; type = types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = '' description = ''
Store the default localhost address. The localhost address.
'';
};
port = mkOption {
type = types.attrsOf types.port;
default = {
http = 80;
https = 443;
jellyfin = 8096;
wireguard-server = 45556;
xray = 50051;
};
description = ''
The mapping from service to ports.
''; '';
}; };
postMaster = mkOption { postMaster = mkOption {
type = types.str; type = types.str;
default = "trivial@${config.constants.domain}"; default = "trivial@${config.constants.domain}";
description = '' description = ''
Store the default post master email address. The post master email address.
''; '';
}; };
publicKeys = mkOption { publicKeys = mkOption {
@ -55,7 +68,7 @@
type = types.str; type = types.str;
default = "macronova"; default = "macronova";
description = '' description = ''
The default username across all devices. The username across all devices.
''; '';
}; };
}; };

View file

@ -1,6 +1,6 @@
{ config, ... }: { { config, ... }: {
networking = { networking = let const = config.constants; in {
domain = config.constants.domain; domain = const.domain;
hostId = "30f8f777"; hostId = "30f8f777";
networkmanager = { networkmanager = {
enable = true; enable = true;
@ -11,7 +11,7 @@
ips = [ "10.32.54.2/32" ]; ips = [ "10.32.54.2/32" ];
peers = [{ peers = [{
allowedIPs = [ "10.32.54.0/24" ]; allowedIPs = [ "10.32.54.0/24" ];
endpoint = "${config.constants.domain}:45556"; endpoint = "${const.domain}:${toString const.port.wireguard-server}";
publicKey = "0j8+alXU/f2UgWN61R6+Wjs9xelGRwpSbe5NyOwWlF4="; publicKey = "0j8+alXU/f2UgWN61R6+Wjs9xelGRwpSbe5NyOwWlF4=";
}]; }];
privateKeyFile = config.sops.secrets."wireguard/${config.networking.hostName}".path; privateKeyFile = config.sops.secrets."wireguard/${config.networking.hostName}".path;

View file

@ -16,7 +16,7 @@
reverse_proxy ${forgejoCfg.HTTP_ADDR}:${toString forgejoCfg.HTTP_PORT} reverse_proxy ${forgejoCfg.HTTP_ADDR}:${toString forgejoCfg.HTTP_PORT}
''; '';
"jellyfin.${dn}".extraConfig = '' "jellyfin.${dn}".extraConfig = ''
reverse_proxy ${lh}:8096 reverse_proxy ${lh}:${toString config.constants.port.jellyfin}
''; '';
"matrix.${dn}".extraConfig = '' "matrix.${dn}".extraConfig = ''
reverse_proxy /_matrix/* ${conduitCfg.address}:${toString conduitCfg.port} reverse_proxy /_matrix/* ${conduitCfg.address}:${toString conduitCfg.port}

View file

@ -1,9 +1,9 @@
{ config, ... }: { config, ... }:
let hn = config.networking.hostName; in { let const = config.constants; hn = config.networking.hostName; in {
networking = { networking = {
domain = config.constants.domain; domain = config.constants.domain;
firewall.allowedTCPPorts = [ 80 443 ]; firewall.allowedTCPPorts = with const.port; [ http https ];
hostId = "e6449321"; hostId = "e6449321";
networkmanager = { networkmanager = {
enable = true; enable = true;
@ -15,7 +15,7 @@ let hn = config.networking.hostName; in {
ips = [ "10.32.54.3/32" ]; ips = [ "10.32.54.3/32" ];
peers = [{ peers = [{
allowedIPs = [ "10.32.54.0/24" ]; allowedIPs = [ "10.32.54.0/24" ];
endpoint = "${config.constants.domain}:45556"; endpoint = "${const.domain}:${toString const.port.wireguard-server}";
persistentKeepalive = 54; persistentKeepalive = 54;
publicKey = "0j8+alXU/f2UgWN61R6+Wjs9xelGRwpSbe5NyOwWlF4="; publicKey = "0j8+alXU/f2UgWN61R6+Wjs9xelGRwpSbe5NyOwWlF4=";
}]; }];

View file

@ -1,7 +1,6 @@
{ config, ... }: { config, ... }:
{ {
services.caddy = { services.caddy = {
enable = true; enable = true;
email = config.constants.postMaster; email = config.constants.postMaster;
@ -17,7 +16,7 @@
"${dn}".extraConfig = let wnm = wn "matrix"; in '' "${dn}".extraConfig = let wnm = wn "matrix"; in ''
header ${wnm}/* Content-Type application/json header ${wnm}/* Content-Type application/json
header ${wnm}/* Access-Control-Allow-Origin * header ${wnm}/* Access-Control-Allow-Origin *
respond ${wnm}/server `{ "m.server": "${mtfqdn}:443" }` respond ${wnm}/server `{ "m.server": "${mtfqdn}:${toString config.constants.port.https}" }`
respond ${wnm}/client `{ respond ${wnm}/client `{
"m.homeserver": { "base_url": "https://${mtfqdn}" }, "m.homeserver": { "base_url": "https://${mtfqdn}" },
"m.identity_server": { "base_url": "https://${mtfqdn}" } "m.identity_server": { "base_url": "https://${mtfqdn}" }

View file

@ -1,22 +1,22 @@
{ config, ... }: { config, ... }:
let hn = config.networking.hostName; in { let hn = config.networking.hostName; port = config.constants.port; wgi = "wgs"; in {
networking = let wg = { interface = "wgs"; port = 45556; }; in { networking = {
domain = config.constants.domain; domain = config.constants.domain;
firewall = { firewall = {
allowedTCPPorts = [ 80 443 50051 ]; allowedTCPPorts = with port; [ http https xray ];
allowedUDPPorts = [ wg.port ]; allowedUDPPorts = with port; [ wireguard-server ];
}; };
hostId = "2cadb253"; hostId = "2cadb253";
nat = { nat = {
enable = true; enable = true;
externalInterface = "ens18"; externalInterface = "ens18";
internalInterfaces = [ wg.interface ]; internalInterfaces = [ wgi ];
}; };
nftables.enable = true; nftables.enable = true;
wireguard.interfaces.${wg.interface} = { wireguard.interfaces.${wgi} = {
ips = [ "10.32.54.76/24" ]; ips = [ "10.32.54.76/24" ];
listenPort = wg.port; listenPort = port.wireguard-server;
peers = [ peers = [
{ {
allowedIPs = [ "10.32.54.2/32" ]; allowedIPs = [ "10.32.54.2/32" ];