aboutsummaryrefslogtreecommitdiff
path: root/nixos
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-12-12 10:47:51 +0100
committerKarel Kočí <cynerd@email.cz>2022-12-12 10:47:51 +0100
commitc4c0b2a9bfb98250e620c92ac6e173a5946464f7 (patch)
tree0d7fc7e44cd4b65beaeaa636f14c632a83c35485 /nixos
parent32faf3d514ca67ffadd712ef10ddf257020c83e1 (diff)
downloadnixos-personal-c4c0b2a9bfb98250e620c92ac6e173a5946464f7.tar.gz
nixos-personal-c4c0b2a9bfb98250e620c92ac6e173a5946464f7.tar.bz2
nixos-personal-c4c0b2a9bfb98250e620c92ac6e173a5946464f7.zip
Add BigClown
Diffstat (limited to 'nixos')
-rw-r--r--nixos/configurations.nix1
-rw-r--r--nixos/machine/spt-mox.nix112
-rw-r--r--nixos/modules/develop.nix2
3 files changed, 115 insertions, 0 deletions
diff --git a/nixos/configurations.nix b/nixos/configurations.nix
index 8977c7c..9754d28 100644
--- a/nixos/configurations.nix
+++ b/nixos/configurations.nix
@@ -7,6 +7,7 @@ let
self.nixosModules."machine-${hostname}"
shellrc.nixosModules.default
usbkey.nixosModules.default
+ nixbigclown.nixosModules.default
(personal-secret.lib.personalSecrets hostname)
{
networking.hostName = hostname;
diff --git a/nixos/machine/spt-mox.nix b/nixos/machine/spt-mox.nix
index 037b10e..b01c48a 100644
--- a/nixos/machine/spt-mox.nix
+++ b/nixos/machine/spt-mox.nix
@@ -7,6 +7,10 @@ with lib;
config = {
+ environment.systemPackages = with pkgs; [
+ mosquitto
+ ];
+
networking.wirelessAP = {
enable = true;
environmentFile = "/run/secrets/hostapd.env";
@@ -58,6 +62,114 @@ with lib;
dhcpcd.allowInterfaces = [ "brlan" ];
};
+ services.mosquitto = {
+ enable = true;
+ listeners = [
+ {
+ users = {
+ cynerd = {
+ acl = ["readwrite #"];
+ passwordFile = "/run/secrets/mosquitto.cynerd.pass";
+ };
+ bigclown = {
+ acl = ["readwrite bigclown/#"];
+ passwordFile = "/run/secrets/mosquitto.bigclown.pass";
+ };
+ };
+ }
+ ];
+ };
+ networking.firewall.allowedTCPPorts = [1883];
+
+ services.bigclown = {
+ gateway = {
+ enable = true;
+ device = "/dev/ttyUSB0";
+ environmentFile = "/run/secrets/bigclown.env";
+ baseTopicPrefix = "bigclown/";
+ mqtt = {
+ username = "bigclown";
+ password = "@PASS_MQTT@";
+ };
+ };
+ mqtt2influxdb = {
+ enable = true;
+ environmentFile = "/run/secrets/bigclown.env";
+ mqtt = {
+ username = "bigclown";
+ password = "@PASS_MQTT@";
+ };
+ influxdb = {
+ host = "cynerd.cz";
+ database = "bigclown";
+ username = "bigclown";
+ password = "@PASS_INFLUXDB@";
+ ssl = true;
+ verify_ssl = false;
+ };
+ points = [
+ {
+ measurement = "temperature";
+ topic = "bigclown/node/+/thermometer/+/temperature";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ channel = "$.topic[4]";
+ };
+ }
+ {
+ measurement = "relative-humidity";
+ topic = "bigclown/node/+/hygrometer/+/relative-humidity";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ channel = "$.topic[4]";
+ };
+ }
+ {
+ measurement = "illuminance";
+ topic = "bigclown/node/+/lux-meter/0:0/illuminance";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ };
+ }
+ {
+ measurement = "pressure";
+ topic = "bigclown/node/+/barometer/0:0/pressure";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ };
+ }
+ {
+ measurement = "voltage";
+ topic = "bigclown/node/+/battery/+/voltage";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ };
+ }
+ {
+ measurement = "button";
+ topic = "bigclown/node/+/push-button/+/event-count";
+ fields.value = "$.payload";
+ tags = {
+ id = "$.topic[2]";
+ channel = "$.topic[4]";
+ };
+ }
+ ];
+ };
+ };
+
+ systemd.services.bigclown-leds = {
+ description = "Bigclown LEDs control";
+ wantedBy = ["multi-user.target"];
+ after = ["mosquitto.service"];
+ serviceConfig.ExecStart = "${pkgs.bigclown-leds}/bin/bigclown-leds /run/secrets/bigclown-leds.ini";
+ };
+
};
}
diff --git a/nixos/modules/develop.nix b/nixos/modules/develop.nix
index 5012fb8..c1c15b2 100644
--- a/nixos/modules/develop.nix
+++ b/nixos/modules/develop.nix
@@ -69,6 +69,8 @@ in {
pylxd
selenium
+ paho-mqtt
+
]))
geckodriver
chromedriver