nixos-config/config/host-config/limina.nix

188 lines
4.5 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
primary-ip = "10.0.0.1";
host-config = config.fudo.hosts.${config.instance.hostname};
site-name = host-config.site;
site = config.fudo.sites.${site-name};
domain-name = host-config.domain;
domain = config.fudo.domains.${domain-name};
2022-03-16 09:49:35 -07:00
# dns-proxy-port = 5335;
in {
config = {
2021-04-12 15:31:55 -07:00
networking = {
interfaces = {
enp1s0 = { useDHCP = true; };
intif0 = {
useDHCP = false;
2022-04-08 14:21:56 -07:00
ipv4 = {
addresses = [{
address = primary-ip;
prefixLength = 16;
}];
routes = [{
address = "192.168.86.0";
prefixLength = 24;
via = "10.0.0.3";
}];
};
};
intif1 = { useDHCP = false; };
intif2 = { useDHCP = false; };
};
2022-03-16 09:49:35 -07:00
enableIPv6 = false;
2021-05-10 18:25:38 -07:00
2022-03-16 09:49:35 -07:00
# nameservers = [ "10.0.0.1" ];
2021-04-12 15:31:55 -07:00
2022-03-16 09:49:35 -07:00
# FIXME: this should be automatic
# firewall.trustedInterfaces =
# [ "intif0" "intif1" "intif2" "lo" "docker0" ];
# nat = {
# enable = true;
# externalInterface = "enp1s0";
# internalInterfaces = [ "intif0" "intif1" "intif2" ];
# };
2022-08-22 11:30:18 -07:00
2023-10-14 16:15:26 -07:00
firewall = {
allowedTCPPorts = [ 80 443 25565 config.services.murmur.port ];
allowedUDPPorts = [ 25565 34197 ];
};
2022-08-22 11:30:18 -07:00
nat.forwardPorts = [
# Minecraft
{
2023-10-14 16:15:26 -07:00
destination = "10.0.0.12:25555";
2022-08-22 11:30:18 -07:00
proto = "tcp";
2022-10-23 13:36:31 -07:00
sourcePort = 25565;
2022-08-22 11:30:18 -07:00
}
{
2023-10-14 16:15:26 -07:00
destination = "10.0.0.12:25555";
2022-08-22 11:30:18 -07:00
proto = "udp";
2022-10-23 13:36:31 -07:00
sourcePort = 25565;
2022-08-22 11:30:18 -07:00
}
# Factorio
{
2023-10-14 16:15:26 -07:00
destination = "10.0.0.12:34197";
2022-08-22 11:30:18 -07:00
proto = "udp";
2022-10-23 13:36:31 -07:00
sourcePort = 34197;
2022-08-22 11:30:18 -07:00
}
];
};
2023-10-14 16:15:26 -07:00
fileSystems = {
"/var/lib/acme" = {
device = "/state/services/acme";
options = [ "bind" ];
};
};
fudo = {
2021-04-12 15:31:55 -07:00
hosts.limina.external-interfaces = [ "enp1s0" ];
2021-04-12 22:15:13 -07:00
2021-11-13 10:30:58 -08:00
client.dns.external-interface = "enp1s0";
garbage-collector = {
enable = true;
timing = "weekly";
};
2022-03-16 09:49:35 -07:00
services = {
local-network = {
enable = true;
internal-interfaces = [ "intif0" "intif1" "intif2" ];
external-interface = "enp1s0";
dns-filter-proxy.enable = true;
};
2022-03-16 09:49:35 -07:00
metrics = {
prometheus.state-directory = "/state/services/prometheus";
};
2022-03-16 09:49:35 -07:00
2023-05-16 22:40:08 -07:00
auth.kerberos.state-directory = "/state/services/heimdal-kdc";
2022-03-16 09:49:35 -07:00
# wireguard-gateway = {
# enable = true;
# network = "10.0.200.0/24";
# peers = {
# niten-phone = {
# public-key = "";
# assigned-ip = "10.0.200.2";
# };
# };
# };
};
};
# Support for statelessness
environment.etc = {
NIXOS.source = "/state/etc/NIXOS";
"host-config.nix".source = "/state/etc/host-config.nix";
};
systemd.tmpfiles.rules = [
2021-10-15 17:39:24 -07:00
"L /etc/adjtime - - - - /state/etc/adjtime"
"L /root/.gnupg - - - - /state/root/gnupg"
"L /root/.ssh/id_rsa - - - - /state/root/ssh/id_rsa"
"L /root/.ssh/id_rsa.pub - - - - /state/root/ssh/id_rsa.pub"
"L /root/.ssh/known_hosts - - - - /state/root/ssh/known_hosts"
2023-10-14 16:15:26 -07:00
"d /state/services/acme 0755 acme acme - -"
];
2022-07-10 20:46:03 -07:00
security.acme.defaults.email = "niten@fudo.org";
2021-04-20 17:53:25 -07:00
2021-07-28 12:01:06 -07:00
systemd.services.nginx.requires = [ "bind.service" ];
2021-04-20 17:53:25 -07:00
services = {
2022-04-08 14:21:56 -07:00
nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
virtualHosts = {
"sea-home.fudo.link" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://home-assist.sea.fudo.org/";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
'';
};
};
};
};
2021-04-20 17:53:25 -07:00
2023-10-14 16:15:26 -07:00
murmur = {
enable = true;
port = 64738;
bonjour = true;
password = "thelittleschool";
};
2021-04-20 17:53:25 -07:00
openssh = {
hostKeys = [
{
path = "/state/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
{
path = "/state/ssh/ssh_host_rsa_key";
type = "rsa";
bits = 4096;
}
];
};
};
};
}