Added basic Home Assistant and routing config for mm

This commit is contained in:
Greg Hellings
2023-06-28 19:14:08 -05:00
parent e75799dbde
commit 413b04990e
4 changed files with 75 additions and 12 deletions
Generated
+3 -3
View File
@@ -177,11 +177,11 @@
}, },
"nixunstable": { "nixunstable": {
"locked": { "locked": {
"lastModified": 1683408522, "lastModified": 1686020360,
"narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "narHash": "sha256-Wee7lIlZ6DIZHHLiNxU5KdYZQl0iprENXa/czzI6Cj4=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", "rev": "4729ffac6fd12e26e5a8de002781ffc49b0e94b7",
"type": "github" "type": "github"
}, },
"original": { "original": {
+1
View File
@@ -37,6 +37,7 @@ in
trusted_proxies = [ "127.0.0.1" "::1" ]; trusted_proxies = [ "127.0.0.1" "::1" ];
server_host = "127.0.0.1"; server_host = "127.0.0.1";
}; };
#"automation manual" = *nix config here* and so on
"automation ui" = "!include automations.yaml"; "automation ui" = "!include automations.yaml";
"script ui" = "!include scripts.yaml"; "script ui" = "!include scripts.yaml";
"scene ui" = "!include scenes.yaml"; "scene ui" = "!include scenes.yaml";
+61 -6
View File
@@ -38,18 +38,27 @@ in
}; };
}; };
firewall = { # Might not strictly be necessary? firewall = { # Might not strictly be necessary?
allowedTCPPorts = [ 53 ]; allowedTCPPorts = [ 53 80 443 8123 ]; # 8091 8123
allowedUDPPorts = [ 53 67 ]; allowedUDPPorts = [ 53 67 ];
}; };
extraHosts = (builtins.concatStringsSep "\n" [
"${lanIpAddress} store.mindmazeroom.com"
]);
}; };
# Serves as the router, DHCP, and DNS for the site # Serves as the router, DHCP, and DNS for the site
greg.router = { greg = {
enable = true; router = {
wan = [ wanInterface "tailscale0" ]; enable = true;
lan = [ lanInterface ]; wan = [ wanInterface "tailscale0" ];
lan = [ lanInterface ];
};
tailscale.enable = true;
proxies = {
"mm.shire-zebra.ts.net".target = "http://127.0.0.1:8123";
"store.mindmazeroom.com".target = "http://127.0.0.1:8123";
};
}; };
greg.tailscale.enable = true;
services = { services = {
dnsmasq = { dnsmasq = {
enable = true; enable = true;
@@ -71,6 +80,39 @@ in
PASSPHRASE = "MindMaze2023"; PASSPHRASE = "MindMaze2023";
}; };
}; };
home-assistant = {
enable = true;
configDir = "/var/lib/hass";
package = (pkgs.home-assistant.override {
extraComponents = [
"accuweather"
"calendar"
"cast"
"lovelace"
];
}).overrideAttrs (oldAttrs: {
doInstallCheck = false;
});
config = {
logger.default = "info";
default_config = {};
esphome = {}; # Get these things loaded, even if not configured
met = {};
my = {};
tts = [ { platform = "google_translate"; } ];
http = {
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" "::1" ];
server_host = "127.0.0.1";
};
"automation manual" = [];
"automation ui" = "!include automations.yaml";
"script manual" = [];
"script ui" = "!include scripts.yaml";
"scene manual" = [];
"scene ui" = "!include scenes.yaml";
};
};
kea.dhcp4 = { kea.dhcp4 = {
enable = true; enable = true;
settings = { settings = {
@@ -97,6 +139,19 @@ in
pools = [{ pools = [{
pool = "10.177.1.10-10.177.1.250"; pool = "10.177.1.10-10.177.1.250";
}]; }];
reservations = [{
hw-address = "9c:8e:cd:3f:3f:8c";
hostname = "madscientist";
ip-address = "10.177.1.249";
} {
hw-address = "9c:8e:cd:3f:40:a4";
hostname = "saloon";
ip-address = "10.177.1.248";
} {
hw-address = "9c:8e:cd:3f:40:d3";
hostname = "jail";
ip-address = "10.177.1.247";
}];
}]; }];
}; };
}; };
+10 -3
View File
@@ -7,12 +7,14 @@ let
wan, wan,
lan, lan,
limitedLan ? [], limitedLan ? [],
openPorts ? [ "ssh" "67" "53" ] # ssh, dhcpd, dns openPorts ? [ "ssh" "67" "53" ], # ssh, dhcpd, dns
openUDPPorts ? [ "67" "53" ] # dhcpd, dns
}: let }: let
lanList = names lan; lanList = names lan;
allLan = names (lan ++ limitedLan); allLan = names (lan ++ limitedLan);
wanName = names wan; wanName = names wan;
portsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${x} accept") openPorts; portsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${toString x} accept") openPorts;
udpPortsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } udp dport ${toString x} accept") openUDPPorts;
in lib.strings.concatStringsSep "\n" [ in lib.strings.concatStringsSep "\n" [
"table ip filter {" "table ip filter {"
" chain input {" " chain input {"
@@ -20,6 +22,7 @@ let
" iifname lo accept" " iifname lo accept"
portsString portsString
udpPortsString
" iifname { ${lanList} } accept comment \"Allows LAN traffic and outgoing\"" " iifname { ${lanList} } accept comment \"Allows LAN traffic and outgoing\""
" iifname { ${wanName} } ct state { established, related } accept comment \"Allows existing connections\"" " iifname { ${wanName} } ct state { established, related } accept comment \"Allows existing connections\""
" iifname { ${wanName} } icmp type { echo-request, destination-unreachable, time-exceeded } counter accept comment \"Allow some ICMP traffic\"" " iifname { ${wanName} } icmp type { echo-request, destination-unreachable, time-exceeded } counter accept comment \"Allow some ICMP traffic\""
@@ -71,7 +74,11 @@ in with lib; {
config = mkIf cfg.enable { config = mkIf cfg.enable {
networking.nftables = { networking.nftables = {
enable = true; enable = true;
ruleset = (nftConfig { lan = cfg.lan; wan = cfg.wan; }); ruleset = (nftConfig {
inherit (cfg) lan wan;
openPorts = config.networking.firewall.allowedTCPPorts;
openUDPPorts = config.networking.firewall.allowedUDPPorts;
});
}; };
environment.systemPackages = [ environment.systemPackages = [