The big variable overhaul

This commit is contained in:
Jimbo 2024-09-23 16:22:01 -04:00
parent 3f0a235dc8
commit 6dab8fc029
36 changed files with 269 additions and 326 deletions

View file

@ -1,13 +1,11 @@
let
ips = import ../modules/ips.nix;
in {
{outputs, ...}: {
# Networking settings
networking = {
# Enable firewall
firewall = {
allowPing = false;
extraInputRules = ''
ip saddr { ${ips.server}, ${ips.wgSpan}.1 } accept comment "Accept Server"
ip saddr { ${outputs.ips.server}, ${outputs.ips.wgSpan}.1 } accept comment "Accept Server"
'';
};
};

View file

@ -4,9 +4,9 @@
packages = with pkgs; [
liberation_ttf
twitter-color-emoji
ubuntu_font_family
noto-fonts
sarasa-gothic
ubuntu_font_family
(nerdfonts.override {fonts = ["UbuntuMono"];})
];
fontconfig.defaultFonts.emoji = ["Twitter Color Emoji"];

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, modulesPath, ... }: let
{ config, lib, pkgs, outputs, modulesPath, ... }: let
# Set common boot paramaters
commonKernelParams = [
# Nvidia settings
@ -100,7 +100,7 @@ in {
options = ["nosuid" "nodev" "noauto"];
};
"/home/jimbo/JimboNFS" = {
device = "server:/export/JimboNFS";
device = "${outputs.ips.server}:/export/JimboNFS";
fsType = "nfs4";
options = ["x-systemd.automount" "_netdev" "nofail" "noauto"];
};

View file

@ -1,11 +0,0 @@
rec {
netInt = "eno1";
localSpan = "10.0.0";
server = "${localSpan}.2";
pc = "${localSpan}.3";
vm = "${localSpan}.4";
hx = "${localSpan}.70";
wgInt = "wg0";
wgSpan = "10.100.0";
}

View file

@ -1,17 +1,7 @@
{
# Networking settings
networking = {
# Choose networking method
wireless.enable = false;
dhcpcd.enable = true;
# Set hostnames
hosts = let
ips = import ../modules/ips.nix;
in {
"${ips.server}" = ["server"];
"${ips.pc}" = ["pc"];
"${ips.vm}" = ["vm"];
};
};
}

View file

@ -4,7 +4,6 @@
# Configure firewall
networking = let
ips = import ../modules/ips.nix;
mailPorts = "{ 25, 143, 465, 587, 993, 4190 }";
in {
firewall = {
@ -12,9 +11,9 @@
# Add extra input rules using nftables
extraInputRules = ''
ip saddr { ${ips.localSpan}.0/24, ${ips.wgSpan}.0/24 } tcp dport 2049 accept comment "Accept NFS"
ip saddr { ${ips.pc}, ${outputs.secrets.lunaIP}, ${outputs.secrets.cornIP}, ${outputs.secrets.vertIP} } tcp dport { 1935, 1945 } accept comment "Accept RTMP"
ip saddr ${ips.wgSpan}.3 tcp dport ${mailPorts} accept comment "Accept mail"
ip saddr { ${outputs.ips.localSpan}.0/24, ${outputs.ips.wgSpan}.0/24 } tcp dport 2049 accept comment "Accept NFS"
ip saddr { ${outputs.ips.pc}, ${outputs.secrets.lunaIP}, ${outputs.secrets.cornIP}, ${outputs.secrets.vertIP} } tcp dport { 1935, 1945 } accept comment "Accept RTMP"
ip saddr ${outputs.ips.wgSpan}.3 tcp dport ${mailPorts} accept comment "Accept mail"
'';
};
@ -27,27 +26,27 @@
content = ''
chain PREROUTING {
type nat hook prerouting priority dstnat; policy accept;
tcp dport 2211 dnat to ${ips.pc}:22 comment "SSH to PC"
tcp dport 2233 dnat to ${ips.wgSpan}.3:22 comment "SSH to Oracle VM"
tcp dport 2211 dnat to ${outputs.ips.pc}:22 comment "SSH to PC"
tcp dport 2233 dnat to ${outputs.ips.wgSpan}.3:22 comment "SSH to Oracle VM"
udp dport { 27005, 27015, 7777 } dnat to ${ips.pc} comment "PC Hosted Games"
udp dport { 27005, 27015, 7777 } dnat to ${outputs.ips.pc} comment "PC Hosted Games"
tcp dport { 58010, 57989, 57984 } dnat to ${ips.pc} comment "PC Sunshine TCP"
udp dport { 57998, 57999, 58000 } dnat to ${ips.pc} comment "PC Sunshine UDP"
tcp dport { 58010, 57989, 57984 } dnat to ${outputs.ips.pc} comment "PC Sunshine TCP"
udp dport { 57998, 57999, 58000 } dnat to ${outputs.ips.pc} comment "PC Sunshine UDP"
tcp dport { 38010, 37989, 37984 } dnat to ${ips.vm} comment "VM Sunshine TCP"
udp dport { 37998, 37999, 38000 } dnat to ${ips.vm} comment "VM Sunshine UDP"
tcp dport { 38010, 37989, 37984 } dnat to ${outputs.ips.vm} comment "VM Sunshine TCP"
udp dport { 37998, 37999, 38000 } dnat to ${outputs.ips.vm} comment "VM Sunshine UDP"
udp dport { 7790, 7791, 7792 } dnat to ${ips.hx} comment "Deus Ex"
udp dport { 7790, 7791, 7792 } dnat to ${outputs.ips.hx} comment "Deus Ex"
ip saddr ${outputs.secrets.cornIP} tcp dport { 9943, 9944 } dnat to ${ips.vm} comment "VM ALVR TCP"
ip saddr ${outputs.secrets.cornIP} udp dport { 9943, 9944 } dnat to ${ips.vm} comment "VM ALVR UDP"
ip saddr ${outputs.secrets.cornIP} tcp dport { 9943, 9944 } dnat to ${outputs.ips.vm} comment "VM ALVR TCP"
ip saddr ${outputs.secrets.cornIP} udp dport { 9943, 9944 } dnat to ${outputs.ips.vm} comment "VM ALVR UDP"
}
chain POSTROUTING {
type nat hook postrouting priority 100; policy accept;
oifname "${ips.netInt}" masquerade
iifname "${ips.netInt}" oifname "${ips.wgInt}" masquerade comment "Traffic from public to WireGuard"
tcp dport ${mailPorts} oifname != "${ips.wgInt}" drop comment "Send mail"
oifname "${outputs.ips.netInt}" masquerade
iifname "${outputs.ips.netInt}" oifname "${outputs.ips.wgInt}" masquerade comment "Traffic from public to WireGuard"
tcp dport ${mailPorts} oifname != "${outputs.ips.wgInt}" drop comment "Send mail"
}
'';
};