From b16ceb22ee61fd89dcddfb0b70df689ae0ccc7d3 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Thu, 20 Aug 2026 21:56:36 +0200 Subject: [PATCH] add mqtt host --- flake.nix | 10 ++++++++++ hosts/mqtt/default.nix | 39 +++++++++++++++++++++++++++++++++++++++ hosts/mqtt/mosquitto.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 hosts/mqtt/default.nix create mode 100644 hosts/mqtt/mosquitto.nix diff --git a/flake.nix b/flake.nix index c03d5d2..989ca94 100644 --- a/flake.nix +++ b/flake.nix @@ -273,6 +273,16 @@ ./hosts/git ]; }; + nixosConfigurations."mqtt" = nixpkgs.lib.nixosSystem { + #system = "x86_64-linux"; + #pkgs = import nixpkgs { inherit system; }; + inherit system; + modules = [ + agenix.nixosModules.default + { environment.systemPackages = [ (agenix.packages.${system}.default) ]; } + ./hosts/mqtt + ]; + }; }; #); } diff --git a/hosts/mqtt/default.nix b/hosts/mqtt/default.nix new file mode 100644 index 0000000..d21dfdc --- /dev/null +++ b/hosts/mqtt/default.nix @@ -0,0 +1,39 @@ +{ ... }: + +{ + imports = [ + ../common.nix + ../../services/openssh.nix + ../../services/prometheus-node.nix + ./mqtt.nix + ]; + + networking = { + hostName = "mqtt"; + firewall = { + allowedTCPPorts = [ + 22 # SSH + 80 # HTTP/1 + 443 # HTTP/2 + ]; + allowedUDPPorts = [ + 443 # HTTP/3 + ]; + }; + }; + + environment.etc."ssh/banner".text = '' + __ __ + /\ \__/\ \__ + ___ ___ __\ \ ,_\ \ ,_\ + /' __` __`\ /'__`\ \ \/\ \ \/ + /\ \/\ \/\ \/\ \L\ \ \ \_\ \ \_ + \ \_\ \_\ \_\ \___, \ \__\\ \__\ + \/_/\/_/\/_/\/___/\ \/__/ \/__/ + \ \_\ + \/_/ + ''; + services.openssh.settings.Banner = "/etc/ssh/banner"; + + system.stateVersion = "26.05"; +} diff --git a/hosts/mqtt/mosquitto.nix b/hosts/mqtt/mosquitto.nix new file mode 100644 index 0000000..862f93d --- /dev/null +++ b/hosts/mqtt/mosquitto.nix @@ -0,0 +1,36 @@ +{ ... }: + +{ + services.mosquitto = { + enable = true; + listeners = [ + { + port = 1883; + settings = { + ptotocol = "mqtt"; + }; + } + { + port = 8083; + settings = { + protocol = "websockets"; + }; + } + ]; + settings = { + allow_zero_length_clientid = true; + autosave_interval = 1800; + autosave_on_changes = true; + connection_messages = true; + allow_anonymous = true; + }; + logDest = "stdout"; + logType = [ + "error" + "warning" + "notice" + "information" + ]; + }; +} +