diff options
Diffstat (limited to 'nixpkgs/pkgs/servers/mqtt')
-rw-r--r-- | nixpkgs/pkgs/servers/mqtt/flashmq/default.nix | 35 | ||||
-rw-r--r-- | nixpkgs/pkgs/servers/mqtt/mosquitto/default.nix | 93 | ||||
-rw-r--r-- | nixpkgs/pkgs/servers/mqtt/nanomq/default.nix | 110 |
3 files changed, 238 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/mqtt/flashmq/default.nix b/nixpkgs/pkgs/servers/mqtt/flashmq/default.nix new file mode 100644 index 000000000000..8a579d948881 --- /dev/null +++ b/nixpkgs/pkgs/servers/mqtt/flashmq/default.nix @@ -0,0 +1,35 @@ +{ lib, stdenv, fetchFromGitHub, cmake, installShellFiles, openssl }: + +stdenv.mkDerivation rec { + pname = "flashmq"; + version = "1.9.1"; + + src = fetchFromGitHub { + owner = "halfgaar"; + repo = "FlashMQ"; + rev = "v${version}"; + hash = "sha256-LxmD/NfD4OJR77erwRnHoe6VRiytqzMlWvRtgY8RD94="; + }; + + nativeBuildInputs = [ cmake installShellFiles ]; + + buildInputs = [ openssl ]; + + installPhase = '' + runHook preInstall + + install -Dm755 flashmq -t $out/bin + installManPage $src/man/*.{1,5} + + runHook postInstall + ''; + + meta = with lib; { + description = "Fast light-weight MQTT broker/server"; + mainProgram = "flashmq"; + homepage = "https://www.flashmq.org/"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ sikmir ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/servers/mqtt/mosquitto/default.nix b/nixpkgs/pkgs/servers/mqtt/mosquitto/default.nix new file mode 100644 index 000000000000..824dcdf62f88 --- /dev/null +++ b/nixpkgs/pkgs/servers/mqtt/mosquitto/default.nix @@ -0,0 +1,93 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, docbook_xsl +, libxslt +, c-ares +, cjson +, libuuid +, libuv +, libwebsockets +, openssl +, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd +, systemd +, uthash +, fetchpatch +, nixosTests +}: + +let + # Mosquitto needs external poll enabled in libwebsockets. + libwebsockets' = (libwebsockets.override { + withExternalPoll = true; + }).overrideAttrs (old: { + # Avoid bug in firefox preventing websockets being created over http/2 connections + # https://github.com/eclipse/mosquitto/issues/1211#issuecomment-958137569 + cmakeFlags = old.cmakeFlags ++ [ "-DLWS_WITH_HTTP2=OFF" ]; + }); + +in +stdenv.mkDerivation rec { + pname = "mosquitto"; + version = "2.0.18"; + + src = fetchFromGitHub { + owner = "eclipse"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-Vs0blV2IhnlEAm0WtOartz+0vLesJfp78FNJCivRxHk="; + }; + + patches = lib.optionals stdenv.isDarwin [ + (fetchpatch { + name = "revert-cmake-shared-to-module.patch"; # See https://github.com/eclipse/mosquitto/issues/2277 + url = "https://github.com/eclipse/mosquitto/commit/e21eaeca37196439b3e89bb8fd2eb1903ef94845.patch"; + sha256 = "14syi2c1rks8sl2aw09my276w45yq1iasvzkqcrqwy4drdqrf069"; + revert = true; + }) + ]; + + postPatch = '' + for f in html manpage ; do + substituteInPlace man/$f.xsl \ + --replace http://docbook.sourceforge.net/release/xsl/current ${docbook_xsl}/share/xml/docbook-xsl + done + ''; + + outputs = [ "out" "dev" "lib" ]; + + nativeBuildInputs = [ cmake docbook_xsl libxslt ]; + + buildInputs = [ + c-ares + cjson + libuuid + libuv + libwebsockets' + openssl + uthash + ] ++ lib.optional withSystemd systemd; + + cmakeFlags = [ + (lib.cmakeBool "WITH_BUNDLED_DEPS" false) + (lib.cmakeBool "WITH_WEBSOCKETS" true) + (lib.cmakeBool "WITH_SYSTEMD" withSystemd) + ]; + + postFixup = '' + sed -i "s|^prefix=.*|prefix=$lib|g" $dev/lib/pkgconfig/*.pc + ''; + + passthru.tests = { + inherit (nixosTests) mosquitto; + }; + + meta = with lib; { + description = "An open source MQTT v3.1/3.1.1/5.0 broker"; + homepage = "https://mosquitto.org/"; + license = licenses.epl10; + maintainers = with maintainers; [ peterhoeg ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/mqtt/nanomq/default.nix b/nixpkgs/pkgs/servers/mqtt/nanomq/default.nix new file mode 100644 index 000000000000..eb4bdf325e91 --- /dev/null +++ b/nixpkgs/pkgs/servers/mqtt/nanomq/default.nix @@ -0,0 +1,110 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, ninja +, pkg-config +, cyclonedds +, libmysqlclient +, mariadb +, mbedtls +, sqlite +, zeromq +, flex +, bison + +# for tests +, python3 +, mosquitto +, netcat-gnu +}: + +let + + # exposing as full package in its own right would be a + # bit absurd - repo doesn't even have a license. + idl-serial = stdenv.mkDerivation { + pname = "idl-serial"; + version = "unstable-2023-03-29"; + + src = fetchFromGitHub { + owner = "nanomq"; + repo = "idl-serial"; + rev = "908c364dab4c0dcdd77b8de698d29c8a0b6d3830"; + hash = "sha256-3DS9DuzHN7BevfgiekUmKKH9ej9wKTrt6Fuh427NC4I="; + }; + + nativeBuildInputs = [ cmake ninja flex bison ]; + + # https://github.com/nanomq/idl-serial/issues/36 + hardeningDisable = [ "fortify3" ]; + }; + +in stdenv.mkDerivation (finalAttrs: { + pname = "nanomq"; + version = "0.20.8"; + + src = fetchFromGitHub { + owner = "emqx"; + repo = "nanomq"; + rev = finalAttrs.version; + hash = "sha256-VCKlXQ7qvBab+wRDnJ6EUA5qaQ36gTFfuerN1GU6sW0="; + fetchSubmodules = true; + }; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "DESTINATION /etc" "DESTINATION $out/etc" + ''; + + nativeBuildInputs = [ cmake ninja pkg-config idl-serial ]; + + buildInputs = [ cyclonedds libmysqlclient mariadb mbedtls sqlite zeromq ]; + + cmakeFlags = [ + "-DBUILD_BENCH=ON" + "-DBUILD_DDS_PROXY=ON" + "-DBUILD_NANOMQ_CLI=ON" + "-DBUILD_ZMQ_GATEWAY=ON" + "-DENABLE_RULE_ENGINE=ON" + "-DNNG_ENABLE_SQLITE=ON" + "-DNNG_ENABLE_TLS=ON" + ]; + + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-return-type -Wno-implicit-function-declaration -Wno-error=implicit-int"; + + # disabled by default - not 100% reliable and making nanomq depend on + # mosquitto would annoy people + doInstallCheck = false; + nativeInstallCheckInputs = [ + mosquitto + netcat-gnu + (python3.withPackages (ps: with ps; [ jinja2 requests paho-mqtt ])) + ]; + installCheckPhase = '' + runHook preInstallCheck + + ( + cd .. + + # effectively distable this test because it is slow + echo > .github/scripts/fuzzy_test.txt + + PATH="$PATH:$out/bin" python .github/scripts/test.py + ) + + runHook postInstallCheck + ''; + + passthru.tests = { + withInstallChecks = finalAttrs.finalPackage.overrideAttrs (_: { doInstallCheck = true; }); + }; + + meta = with lib; { + description = "An ultra-lightweight and blazing-fast MQTT broker for IoT edge"; + homepage = "https://nanomq.io/"; + license = licenses.mit; + maintainers = with maintainers; [ sikmir ]; + platforms = platforms.unix; + }; +}) |