From b309200640206fb010322125cc1373ffd9ecd00a Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Sun, 26 Nov 2023 18:41:45 -0800 Subject: [PATCH] Added mosquitto as mqtt broker --- .../nixos/services/homeassistant/default.nix | 2 + modules/nixos/services/mosquitto/default.nix | 45 ++++++++++++++++++ secrets/cf_dns_kilonull.age | 25 +++++----- secrets/hass_mqtt.age | Bin 0 -> 520 bytes secrets/nextcloud_admin.age | Bin 402 -> 468 bytes secrets/secrets.nix | 2 + secrets/theengs_ble_mqtt.age | 9 ++++ systems/aarch64-linux/pi4/default.nix | 1 + 8 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 modules/nixos/services/mosquitto/default.nix create mode 100644 secrets/hass_mqtt.age create mode 100644 secrets/theengs_ble_mqtt.age diff --git a/modules/nixos/services/homeassistant/default.nix b/modules/nixos/services/homeassistant/default.nix index 5d7e7a0..a57d03b 100644 --- a/modules/nixos/services/homeassistant/default.nix +++ b/modules/nixos/services/homeassistant/default.nix @@ -33,6 +33,8 @@ in { extraComponents = [ "hue" "met" + "mqtt" + "octoprint" "tuya" "vizio" "zeroconf" diff --git a/modules/nixos/services/mosquitto/default.nix b/modules/nixos/services/mosquitto/default.nix new file mode 100644 index 0000000..8ef4232 --- /dev/null +++ b/modules/nixos/services/mosquitto/default.nix @@ -0,0 +1,45 @@ +{ + options, + config, + lib, + pkgs, + format, + ... +}: +with lib; let + cfg = config.aa.services.mosquitto; + mosquitto_cfg = config.services.mosquitto; +in { + options.aa.services.mosquitto = with types; { + enable = mkEnableOption "home assistant"; + }; + config = mkIf cfg.enable { + age.secrets = { + hass_mqtt.file = ../../../../secrets/hass_mqtt.age; + theengs_ble_mqtt.file = ../../../../secrets/theengs_ble_mqtt.age; + }; + + services.mosquitto = { + enable = true; + listeners = [ + { + users = { + hass = { + acl = [ + "read home/#" + "readwrite homeassistant/status" + ]; + passwordFile = config.age.secrets.hass_mqtt.path; + }; + theengs_ble_gateway = { + acl = ["readwrite home/#"]; + passwordFile = config.age.secrets.theengs_ble_mqtt.path; + }; + }; + } + ]; + }; + + networking.firewall.allowedTCPPorts = [1883]; + }; +} diff --git a/secrets/cf_dns_kilonull.age b/secrets/cf_dns_kilonull.age index d9d3255..2b90162 100644 --- a/secrets/cf_dns_kilonull.age +++ b/secrets/cf_dns_kilonull.age @@ -1,14 +1,13 @@ age-encryption.org/v1 --> ssh-ed25519 Yk7ehg NwKwWQiMTehA+gluPXpVyL4zyhGRheQ1hCyyjPyWNlM -ZTD2ssehxzayPhnW+OVqXzr/fqQ7Hdm711RgZT5R4Pw --> ssh-ed25519 SYNSNQ oEc4p7cz7u+gEYIJVW7hl+VXwXzPSpRXCL33Ij2ZIkc -avgbK9ss20KmL1XB9Sg45bwv6BItDcMJj8/e2fXxZOE --> ssh-ed25519 t5XIGA huqEOk8X1Z4g4pcjAc6griyt3x+hU5NWMfCUL8WoUkI -yqJxaxWF04PzcmyFN8hq+u9DaQmbI4W3PSDC2+Rxr5I --> piv-p256 UIEGzg AzYN661WI0nUCA4MHnSqOT0A23jbBl9Dnv5CmmJkvuSk -BXxeYW5RdiYNwtMG+PHF5b7x2Pu129SNOeqItwfcWTs --> X{\S-grease <0c[|Bb -tXXujcfm/3s/TMaX5tM9TamHAEHSUCArwJCDEJ2SFKcL8FSV1N3srp4wNogtF7pO -PjLeXFHo ---- 1VR3EGzzVvK+pbDlvomJ6cJ9wOrP2LoPsUqmh0c6bVE ->/,+bLjgf<9mKTN3w¹1(&D 72#.^"KW$BKUknDXk7GRڡd^9`єyM-KvO##8_<u:;\A0X5) \ No newline at end of file +-> ssh-ed25519 Yk7ehg YW+VO4Mb5SxfM9mxXRvYKC2kJVZeULkllzvUbo0VShM +yOts+jZvdreDDC13fT/4BdF7d/B03RaGlDzSwBGa6Q8 +-> ssh-ed25519 SYNSNQ tdbAwQABaA+r2Kkm7d9UIsVC7J/LtmlI1rnbQOlkYQU +sJfnI9RdEoYaI7+rlrG+N4cTxdWRX2XDDzjuql5CYhI +-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