From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id qONmHPbXZ2cr8AAAe85BDQ:P1 (envelope-from ) for ; Sun, 22 Dec 2024 09:12:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id qONmHPbXZ2cr8AAAe85BDQ (envelope-from ) for ; Sun, 22 Dec 2024 10:12:22 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=k9T9HK42; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734858742; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=xJcUE/x37QzO5iVQhbYFtsISywrOlEv95R713+EY1ek=; b=pRrS1H0nVTzxBK/ZVkhTEj78yUCGZqGZGnu+ldhSf0ryNsAivbeSu6dX8lxmfPv4zDHY3O RqkosUBPbMOZCJtpRghkuaR+Gq/Vr3PaqDjxWi22yZ12i7RU5RhQz7QV6Ft1VyDOuJmMJJ O8bdc4nBTn2aUvXso0Lc/KBg4TTcfqnnWrloc7tzcKAob7tv4vR3FQpEfo0tBtaSXO4aW5 RKkmtGTTyuzudwuW1bB52sX+cF5rR/6dx+zQNI0wUWDj6zHTplCI7P3N6iF1Sd8HgNz7+G Yx5MANyWxEVA8AghjjwhRRdISn+lpxxrtDwhAyK8ejLdMCxtogJ0RSDWmGpe6g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=k9T9HK42; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734858742; a=rsa-sha256; cv=none; b=ZqhggLV+8GOVMwIkHcmcHixP2s93Y7Y5Lpr9OI3CEGy0lH1/UFnsfFJV7JW6DHO/mwcFRP VWLxEtDLoSXGYSB0NOXf8iEJBlUzIVPuplJWn89u8Pn0RIl+UcK5IYzgFZPOvt6Q3eB2vD rEy9Hhn1RZ0IKhCl57/QNdqUu3BzJydYW/ThQGTYCcJoKX9uKYK/nw/Cxm9qhp9Pa7ZasB +MUrGsBtvTfvlDGzTDNZ7BC8Izi6nuEU8U+NJlLAlDus72JXsZ8UBLhTjVWd1jTD28V8dM k+wm/xfOgj/7gxEALpQQHqGOM81hHno4ghFw+2hwoW2+hLzq/fPJ8+TLVIrgqA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A4CB27833C for ; Sun, 22 Dec 2024 10:12:21 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPI0L-0004Wn-47; Sun, 22 Dec 2024 04:12:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPI0I-0004Vy-Mw for guix-patches@gnu.org; Sun, 22 Dec 2024 04:12:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPI0I-0003lw-Dz for guix-patches@gnu.org; Sun, 22 Dec 2024 04:12:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=xJcUE/x37QzO5iVQhbYFtsISywrOlEv95R713+EY1ek=; b=k9T9HK42V9gw9f/McjCaI9ygdfV4JJWpDM31D5zuMeagBaYljjjXiKh3sMSvTW/1GyUu6QqJ0VEv94HwsFpGy/lidwaiWGKj6fzR9VjdmZMCndl+urisW9wAdFJyPa66LVOjWPXF3PYDhAJ70vtQs2+L1vMlopVZiAHXXtA45Es6GFPwQSNWSA+7A8Y2qwjje0ApHOROiRP1kPq4Gm7DEoRH8AC7Q0LonXzR2ksG27fDSENllnX543G0bwc4HpbghPyACA0erEN33sbWmCxlFgJvTnvgLvhqTbBGBsQqwXbmVvG+V18mUnrp6hT4oaXyOUgtZWwVaGtwVEE+sDKSGQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tPI0I-0000AI-3t for guix-patches@gnu.org; Sun, 22 Dec 2024 04:12:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75021] [PATCH] services: Add mosquitto-service-type. Resent-From: Evgeny Pisemsky Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 22 Dec 2024 09:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75021 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75021@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1734858671559 (code B ref -1); Sun, 22 Dec 2024 09:12:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 Dec 2024 09:11:11 +0000 Received: from localhost ([127.0.0.1]:49003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPHzS-00008x-Kn for submit@debbugs.gnu.org; Sun, 22 Dec 2024 04:11:11 -0500 Received: from lists.gnu.org ([209.51.188.17]:47476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPHzQ-00008n-8P for submit@debbugs.gnu.org; Sun, 22 Dec 2024 04:11:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPHzO-0004TG-Jn for guix-patches@gnu.org; Sun, 22 Dec 2024 04:11:06 -0500 Received: from sofi-shared.hosting.energy ([2001:41d0:602:1f56::] helo=sofi.hosting.energy) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPHzJ-0003eD-65 for guix-patches@gnu.org; Sun, 22 Dec 2024 04:11:05 -0500 Received: from [212.233.86.182] (helo=laptop) by sofi.hosting.energy with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1tPHzB-00046n-FC for guix-patches@gnu.org; Sun, 22 Dec 2024 12:10:53 +0300 From: Evgeny Pisemsky Date: Sun, 22 Dec 2024 12:10:51 +0300 Message-ID: <87cyhkytes.fsf@pisemsky.site> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-services-Add-mosquitto-service-type.patch Content-Transfer-Encoding: quoted-printable Received-SPF: permerror client-ip=2001:41d0:602:1f56::; envelope-from=mail@pisemsky.site; helo=sofi.hosting.energy X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.4, T_SPF_HELO_PERMERROR=0.01, T_SPF_PERMERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -7.39 X-Spam-Score: -7.39 X-Migadu-Queue-Id: A4CB27833C X-TUID: g9w+Y/bvxBGi >From b7dce453fc4dd29309687b2eb5bea99663b44212 Mon Sep 17 00:00:00 2001 Message-ID: From: Evgeny Pisemsky Date: Sun, 22 Dec 2024 12:00:50 +0300 Subject: [PATCH] services: Add mosquitto-service-type. Change-Id: I65c141a1aac4a932a8eead86626e4284346c1d91 --- doc/guix.texi | 32 +++++++++++++++++ gnu/services/messaging.scm | 71 +++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index f7b7569887..55cfbbceac 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -134,6 +134,7 @@ Copyright @copyright{} 2024 Nigko Yerden@* Copyright @copyright{} 2024 Troy Figiel@* Copyright @copyright{} 2024 Sharlatan Hellseher@* +Copyright @copyright{} 2024 Evgeny Pisemsky@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -29403,6 +29404,37 @@ Messaging Services @end table @end deftp =20 +@subsubheading Mosquitto Service + +@url{https://mosquitto.org/,Mosquitto} is a lightweight message broker +that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. It is +suitable for use on all devices from low power single board computers to +full servers. + +@defvar mosquitto-service-type +This is the service type for the @url{https://mosquitto.org/,Mosquitto} +MQTT broker. Its value is a @code{mosquitto-configuration} (see below). +@end defvar + +@deftp {Data Type} mosquitto-configuration +This is the configuration for Mosquitto, with the following fields: + +@table @asis +@item @code{package} (default: @code{mosquitto}) +The Mosquitto package to use. + +@item @code{config-file} (default: @code{#f}) +The Mosquitto configuration file as a file-like object or the value +@code{#f} to use the default configuration. + +@item @code{user} (default: @code{"mosquitto"}) +Owner of the broker process. + +@item @code{group} (default: @code{"mosquitto"}) +Owner's group of the broker process. +@end table +@end deftp + @node Telephony Services @subsection Telephony Services =20 diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index a914d0f89e..056aa8b207 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -3,6 +3,7 @@ ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2015, 2017-2020, 2022-2024 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2018 Pierre-Antoine Rouby +;;; Copyright =C2=A9 2024 Evgeny Pisemsky ;;; ;;; This file is part of GNU Guix. ;;; @@ -59,7 +60,15 @@ (define-module (gnu services messaging) bitlbee-service-type =20 quassel-configuration - quassel-service-type)) + quassel-service-type + + mosquitto-configuration + mosquitto-configuration? + mosquitto-configuration-package + mosquitto-configuration-config-file + mosquitto-configuration-user + mosquitto-configuration-group + mosquitto-service-type)) =20 ;;; Commentary: ;;; @@ -1002,3 +1011,63 @@ (define quassel-service-type "Run @url{https://quassel-irc.org/,quasselcore}, the back= end for the distributed IRC client quassel, which allows you to connect from multiple machines simultaneously."))) + +;;; +;;; Mosquitto. +;;; + +(define-record-type* + mosquitto-configuration + make-mosquitto-configuration + mosquitto-configuration? + (package mosquitto-configuration-package + (default mosquitto)) + (config-file mosquitto-configuration-config-file + (default #f)) + (user mosquitto-configuration-user + (default "mosquitto")) + (group mosquitto-configuration-group + (default "mosquitto"))) + +(define (mosquitto-accounts config) + (match-record config + (user group) + (filter identity + (list + (and (equal? group "mosquitto") + (user-group + (name "mosquitto") + (system? #t))) + (and (equal? user "mosquitto") + (user-account + (name "mosquitto") + (group group) + (system? #t) + (comment "bzzz") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin")))))))) + +(define (mosquitto-shepherd-service config) + (match-record config + (package config-file user group) + (list (shepherd-service + (documentation "Run the Mosquitto MQTT broker.") + (provision '(mosquitto)) + (requirement '(networking syslogd user-processes)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/mosquitto") + #$@(if config-file + (list "-c" config-file) + '())) + #:user #$user + #:group #$group)) + (stop #~(make-kill-destructor)))))) + +(define mosquitto-service-type + (service-type + (description "Run the Mosquitto MQTT broker.") + (name 'mosquitto) + (extensions + (list (service-extension account-service-type mosquitto-accounts) + (service-extension shepherd-root-service-type mosquitto-shepherd= -service))) + (default-value (mosquitto-configuration)))) base-commit: 02e6fa8f923849afa0d46f81262936880000664f --=20 2.46.0