mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-10 14:50:40 +02:00
parent
fcc462879e
commit
a5f3c92a30
8 changed files with 4 additions and 111 deletions
|
@ -25,7 +25,6 @@
|
|||
./influxdb.nix
|
||||
./mosquitto.nix
|
||||
./wyoming.nix
|
||||
./zigbee2mqtt.nix
|
||||
];
|
||||
|
||||
topology.self.hardware.info = "Intel N100, 16GB RAM";
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
age.secrets.mosquitto-pw-zigbee2mqtt = {
|
||||
mode = "440";
|
||||
owner = "zigbee2mqtt";
|
||||
group = "mosquitto";
|
||||
generator.script = "alnum";
|
||||
};
|
||||
|
||||
age.secrets.mosquitto-pw-home-assistant = {
|
||||
mode = "440";
|
||||
owner = "hass";
|
||||
|
@ -21,10 +14,10 @@
|
|||
{
|
||||
acl = [ "pattern readwrite #" ];
|
||||
users = {
|
||||
zigbee2mqtt = {
|
||||
passwordFile = config.age.secrets.mosquitto-pw-zigbee2mqtt.path;
|
||||
acl = [ "readwrite #" ];
|
||||
};
|
||||
# zigbee2mqtt = {
|
||||
# passwordFile = config.age.secrets.mosquitto-pw-zigbee2mqtt.path;
|
||||
# acl = [ "readwrite #" ];
|
||||
# };
|
||||
home_assistant = {
|
||||
passwordFile = config.age.secrets.mosquitto-pw-home-assistant.path;
|
||||
acl = [ "readwrite #" ];
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
config,
|
||||
globals,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
zigbee2mqttDomain = "zigbee.${globals.domains.personal}";
|
||||
in
|
||||
{
|
||||
wireguard.proxy-home.firewallRuleForNode.ward-web-proxy.allowedTCPPorts = [
|
||||
config.services.zigbee2mqtt.settings.frontend.port
|
||||
];
|
||||
|
||||
globals.services.zigbee2mqtt.domain = zigbee2mqttDomain;
|
||||
# globals.monitoring.http.homeassistant = {
|
||||
# url = "https://${homeasisstantDomain}";
|
||||
# expectedBodyRegex = "homeassistant";
|
||||
# network = "internet";
|
||||
# };
|
||||
|
||||
services.zigbee2mqtt = {
|
||||
enable = true;
|
||||
package = pkgs.zigbee2mqtt_2;
|
||||
settings = {
|
||||
advanced = {
|
||||
log_level = "info";
|
||||
channel = 25;
|
||||
};
|
||||
homeassistant = true;
|
||||
permit_join = false;
|
||||
serial = {
|
||||
port = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:5.4:1.0-port0";
|
||||
adapter = "zstack";
|
||||
};
|
||||
mqtt = {
|
||||
server = "mqtt://localhost:1883";
|
||||
user = "zigbee2mqtt";
|
||||
password = "!/run/zigbee2mqtt/secrets.yaml mosquitto-pw";
|
||||
};
|
||||
frontend.port = 8072;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.zigbee2mqtt = {
|
||||
serviceConfig = {
|
||||
RuntimeDirectory = "zigbee2mqtt";
|
||||
LoadCredential = [
|
||||
"mosquitto-pw-zigbee2mqtt:${config.age.secrets.mosquitto-pw-zigbee2mqtt.path}"
|
||||
];
|
||||
};
|
||||
preStart = lib.mkBefore ''
|
||||
# Update mosquitto password
|
||||
# We don't use -i because it would require chown with is a @privileged syscall
|
||||
MOSQUITTO_PW="$(cat "$CREDENTIALS_DIRECTORY/mosquitto-pw-zigbee2mqtt")" \
|
||||
${lib.getExe pkgs.yq-go} '.mosquitto-pw = strenv(MOSQUITTO_PW)' \
|
||||
/dev/null > /run/zigbee2mqtt/secrets.yaml
|
||||
'';
|
||||
};
|
||||
|
||||
nodes.ward-web-proxy = {
|
||||
services.nginx = {
|
||||
upstreams."zigbee2mqtt" = {
|
||||
servers."${config.wireguard.proxy-home.ipv4}:${toString config.services.zigbee2mqtt.settings.frontend.port}" =
|
||||
{ };
|
||||
extraConfig = ''
|
||||
zone zigbee2mqtt 64k;
|
||||
keepalive 2;
|
||||
'';
|
||||
};
|
||||
virtualHosts.${zigbee2mqttDomain} = {
|
||||
forceSSL = true;
|
||||
useACMEWildcardHost = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://zigbee2mqtt";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
allow ${globals.net.home-lan.vlans.home.cidrv4};
|
||||
allow ${globals.net.home-lan.vlans.home.cidrv6};
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -19,7 +19,6 @@ let
|
|||
globals.services.paperless.domain
|
||||
globals.services.esphome.domain
|
||||
globals.services.home-assistant.domain
|
||||
globals.services.zigbee2mqtt.domain
|
||||
"fritzbox.${globals.domains.personal}"
|
||||
];
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ let
|
|||
globals.services.paperless.domain
|
||||
globals.services.esphome.domain
|
||||
globals.services.home-assistant.domain
|
||||
globals.services.zigbee2mqtt.domain
|
||||
"fritzbox.${globals.domains.personal}"
|
||||
];
|
||||
in
|
||||
|
|
|
@ -119,7 +119,6 @@ in
|
|||
globals.services.paperless.domain
|
||||
globals.services.esphome.domain
|
||||
globals.services.home-assistant.domain
|
||||
globals.services.zigbee2mqtt.domain
|
||||
"fritzbox.${globals.domains.personal}"
|
||||
];
|
||||
filters = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue