dots/modules/hosts/nixos/hetznix01/post-install/mosquitto.nix
Gene Liverman 9298bc7caf
Replace hardcoded tailnet name and WiFi SSIDs with private-flake options
Tailnet name (atlas-snares.ts.net) is now sourced from
config.private-flake.tailnetDomain, defined in private-flake's
shared/tailnet.nix and imported by the hetznix01 and nixnuc modules.

WiFi SSIDs for kiosk-* hosts are now set by private-flake's
shared/kiosk.nix via nixosModules.private.kiosk; the hardcoded network
blocks are removed from the kiosk dots configs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 18:01:01 -04:00

135 lines
3.5 KiB
Nix

{ config, ... }:
let
mqtt_domain = "mqtt.technicalissues.us";
in
{
security.acme.certs.${mqtt_domain}.postRun =
"systemctl restart ${config.systemd.services.mosquitto.name}";
services.mosquitto = {
enable = true;
bridges = {
liamcottle = {
addresses = [
{
address = "mqtt.meshtastic.liamcottle.net";
port = 1883;
}
];
topics = [
"msh/# out 1 \"\""
];
settings = {
remote_username = "uplink";
remote_password = "uplink";
cleansession = true;
keepalive_interval = 160;
notifications = false;
start_type = "automatic";
};
};
meshtastic = {
addresses = [
{
address = "mqtt.meshtastic.org";
port = 1883;
}
];
topics = [
"msh/# out 1 \"\""
];
settings = {
remote_username = "meshdev";
remote_password = "large4cats";
#bridge_protocol_version = "mqttv311";
cleansession = true;
keepalive_interval = 160;
notifications = false;
start_type = "automatic";
};
};
homeassistant = {
addresses = [
{
address = "homeasistant-lc.${config.private-flake.tailnetDomain}";
port = 1883;
}
];
topics = [
"msh/US/2/e/LongFast/!a386c80 out 1 \"\""
"msh/US/2/e/LongFast/!b03bcb24 out 1 \"\""
"msh/US/2/e/LongFast/!b03dbe58 out 1 \"\""
"msh/US/2/e/LongFast/!4370b0c6 out 1 \"\""
];
settings = {
remote_username = "meshtastic_user";
remote_password = "meshtastic_user";
cleansession = true;
keepalive_interval = 160;
notifications = false;
start_type = "automatic";
};
};
};
listeners =
let
mqtt_users = {
genebean = {
acl = [
"readwrite msh/#"
];
hashedPasswordFile = config.sops.secrets.mosquitto_genebean.path;
};
mountain_mesh = {
acl = [
"readwrite msh/#"
];
hashedPasswordFile = config.sops.secrets.mosquitto_mountain_mesh.path;
};
};
in
[
{
port = 1883;
users = mqtt_users;
settings.allow_anonymous = false;
}
{
port = 8883;
users = mqtt_users;
settings =
let
certDir = config.security.acme.certs."${mqtt_domain}".directory;
in
{
allow_anonymous = false;
keyfile = certDir + "/key.pem";
certfile = certDir + "/cert.pem";
cafile = certDir + "/chain.pem";
};
}
{
port = 9001;
users = mqtt_users;
settings =
let
certDir = config.security.acme.certs."${mqtt_domain}".directory;
in
{
allow_anonymous = false;
keyfile = certDir + "/key.pem";
certfile = certDir + "/cert.pem";
cafile = certDir + "/chain.pem";
protocol = "websockets";
};
}
];
};
sops.secrets = {
mosquitto_genebean.owner = config.users.users.mosquitto.name;
mosquitto_mountain_mesh.owner = config.users.users.mosquitto.name;
};
users.users.mosquitto.extraGroups = [ "nginx" ];
}