2020-10-11 10:49:06 +02:00
|
|
|
{ config, pkgs, ... }:
|
2020-10-03 16:32:06 +02:00
|
|
|
|
2020-10-21 20:54:55 +02:00
|
|
|
with pkgs;
|
|
|
|
|
2020-10-22 19:15:55 +02:00
|
|
|
let
|
|
|
|
mqttDomain = "mqtt.${config.networking.domain}";
|
|
|
|
in
|
2020-10-21 20:54:55 +02:00
|
|
|
{
|
2020-10-07 14:37:57 +02:00
|
|
|
environment.systemPackages = with pkgs; [ deconz ];
|
|
|
|
|
|
|
|
local.services.deconz = {
|
|
|
|
enable = true;
|
|
|
|
httpPort = 8080;
|
|
|
|
wsPort = 1443;
|
|
|
|
openFirewall = true;
|
|
|
|
};
|
|
|
|
|
2020-10-22 19:15:55 +02:00
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
${ mqttDomain } = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:${toString config.services.mosquitto.port}";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-10-21 20:54:55 +02:00
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
2020-10-22 19:15:55 +02:00
|
|
|
config.services.mosquitto.port
|
2020-10-21 20:54:55 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
services.mosquitto = {
|
|
|
|
enable = true;
|
|
|
|
host = "0.0.0.0";
|
|
|
|
checkPasswords = true;
|
2020-10-22 19:15:55 +02:00
|
|
|
extraConf = ''
|
|
|
|
protocol websockets
|
|
|
|
'';
|
2020-10-21 20:54:55 +02:00
|
|
|
users = {
|
|
|
|
"hass" = {
|
|
|
|
acl = [
|
|
|
|
"topic readwrite homeassistant/#"
|
|
|
|
"topic readwrite tasmota/#"
|
|
|
|
"topic readwrite owntracks/#"
|
|
|
|
];
|
|
|
|
hashedPasswordFile = "/etc/nixos/secrets/mqtt/hass";
|
|
|
|
};
|
2020-10-22 19:15:55 +02:00
|
|
|
#"tasmota" = {
|
|
|
|
# acl = [
|
|
|
|
# "topic readwrite tasmota/#"
|
|
|
|
# ];
|
|
|
|
# hashedPasswordFile = "/etc/nixos/secrets/mqtt/tasmota";
|
|
|
|
#};
|
2020-10-21 20:54:55 +02:00
|
|
|
"owntracks" = {
|
|
|
|
acl = [
|
|
|
|
"topic readwrite owntracks/#"
|
|
|
|
];
|
|
|
|
hashedPasswordFile = "/etc/nixos/secrets/mqtt/owntracks";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-10-03 16:32:06 +02:00
|
|
|
services.home-assistant = {
|
|
|
|
enable = true;
|
2020-10-07 14:37:57 +02:00
|
|
|
package = home-assistant.override {
|
2020-10-22 19:15:55 +02:00
|
|
|
extraPackages = ps: with ps; [
|
|
|
|
(callPackage pydeconz { })
|
|
|
|
];
|
2020-10-07 14:37:57 +02:00
|
|
|
};
|
2020-10-03 16:32:06 +02:00
|
|
|
openFirewall = true;
|
|
|
|
config = {
|
|
|
|
homeassistant = {
|
|
|
|
name = "Home";
|
|
|
|
latitude = "!secret latitude";
|
|
|
|
longitude = "!secret longitude";
|
|
|
|
elevation = 0;
|
|
|
|
unit_system = "metric";
|
|
|
|
temperature_unit = "C";
|
|
|
|
external_url = "https://home.felschr.com";
|
|
|
|
internal_url = "http://192.168.86.233:8123";
|
|
|
|
};
|
2020-10-11 10:13:22 +02:00
|
|
|
default_config = { };
|
|
|
|
config = { };
|
|
|
|
frontend = { };
|
|
|
|
mobile_app = { };
|
|
|
|
discovery = { };
|
|
|
|
zeroconf = { };
|
|
|
|
ssdp = { };
|
|
|
|
shopping_list = { };
|
2020-10-07 14:37:57 +02:00
|
|
|
deconz = {
|
|
|
|
host = "localhost";
|
|
|
|
port = 8080;
|
2020-10-11 10:13:22 +02:00
|
|
|
api_key = "!secret deconz_apikey";
|
2020-10-07 14:37:57 +02:00
|
|
|
};
|
2020-10-21 20:54:55 +02:00
|
|
|
mqtt = {
|
|
|
|
broker = "localhost";
|
|
|
|
port = "8883";
|
|
|
|
username = "hass";
|
|
|
|
password = "!secret mqtt_password";
|
|
|
|
discovery = true;
|
|
|
|
discovery_prefix = "homeassistant";
|
|
|
|
};
|
|
|
|
owntracks = {
|
|
|
|
mqtt_topic = "owntracks/#";
|
|
|
|
};
|
2020-10-03 16:32:06 +02:00
|
|
|
};
|
|
|
|
# configWritable = true; # doesn't work atm
|
|
|
|
};
|
|
|
|
}
|