From patchwork Fri Dec 27 15:30:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evgeny Pisemsky X-Patchwork-Id: 35862 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 02B2D27BBE9; Fri, 27 Dec 2024 15:33:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 12AE527BBE2 for ; Fri, 27 Dec 2024 15:33:26 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRCKs-0005QP-Nj; Fri, 27 Dec 2024 10:33:10 -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 1tRCKl-0005Ii-VM for guix-patches@gnu.org; Fri, 27 Dec 2024 10:33:04 -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 1tRCKl-0002yt-2v for guix-patches@gnu.org; Fri, 27 Dec 2024 10:33:03 -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:In-Reply-To:References:Subject; bh=72jYwxv0Wu8AV3U5EdDSluCN9Dw9TjkmJhI9GkdpQTk=; b=PYNUCU/ycgJhbSa0hHUcLX5vDCHe7E5Nfo1XVKzQfHN6ZyXTowlTdIhlaqDR5vsyQxnH6InaLszxfN2Gm7pgb84PO0lRXn2hzCwPqBpbFEYPTRpCqFCjGD3kEmfcwkmBsGiWMmYICGRXiM/q0A2W2uGilU93UwQTtd+XkUOkHLJVm8ihY16xF9ztQHgcncTDMOpG3GDFeAAdX1C3FTNiRCmCTlPXh3IrzfCRNkbpO0PDR+fH4DHExMpkGnjHRtPCTYJshMmofQdf3RJkTpA4Z1dJhO7b8dA+0kFEOXlyqoD7iNvV/wVLlCuTzOxymCmZXToP2CKTMd52pdOiqh80pQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tRCKk-0007l0-FP for guix-patches@gnu.org; Fri, 27 Dec 2024 10:33:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75021] [PATCH] services: Add mosquitto-service-type. References: <87cyhkytes.fsf@pisemsky.site> In-Reply-To: <87cyhkytes.fsf@pisemsky.site> Resent-From: Evgeny Pisemsky Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Dec 2024 15:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75021 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75021@debbugs.gnu.org Received: via spool by 75021-submit@debbugs.gnu.org id=B75021.173531356829772 (code B ref 75021); Fri, 27 Dec 2024 15:33:02 +0000 Received: (at 75021) by debbugs.gnu.org; 27 Dec 2024 15:32:48 +0000 Received: from localhost ([127.0.0.1]:47261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRCKV-0007k4-5s for submit@debbugs.gnu.org; Fri, 27 Dec 2024 10:32:47 -0500 Received: from sofi-shared.hosting.energy ([146.59.24.90]:36493 helo=sofi.hosting.energy) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRCKQ-0007jf-N6 for 75021@debbugs.gnu.org; Fri, 27 Dec 2024 10:32:45 -0500 Received: from [212.233.86.93] (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 1tRCIG-0002Nl-Qx for 75021@debbugs.gnu.org; Fri, 27 Dec 2024 18:30:29 +0300 From: Evgeny Pisemsky Date: Fri, 27 Dec 2024 18:30:26 +0300 Message-ID: <87h66prvn1.fsf@pisemsky.site> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches I have described changes in a commit message. From 06968ec1b2849441633be2392160dc2793e676ac Mon Sep 17 00:00:00 2001 Message-ID: <06968ec1b2849441633be2392160dc2793e676ac.1735312937.git.mail@pisemsky.site> From: Evgeny Pisemsky Date: Fri, 27 Dec 2024 18:18:01 +0300 Subject: [PATCH] services: Add mosquitto-service-type. * gnu/services/messaging.scm (): New record type. (mosquitto-accounts): New procedure. (mosquitto-shepherd-service): New procedure. (mosquitto-service-type): New variable. * doc/guix.texi (Messaging Services): Document it. 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 da4d2f5ebc..80ebfe4cae 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@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -29414,6 +29415,37 @@ Messaging Services @end table @end deftp +@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 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 © 2017 Mathieu Othacehe ;;; Copyright © 2015, 2017-2020, 2022-2024 Ludovic Courtès ;;; Copyright © 2018 Pierre-Antoine Rouby +;;; Copyright © 2024 Evgeny Pisemsky ;;; ;;; This file is part of GNU Guix. ;;; @@ -59,7 +60,15 @@ (define-module (gnu services messaging) bitlbee-service-type 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)) ;;; Commentary: ;;; @@ -1002,3 +1011,63 @@ (define quassel-service-type "Run @url{https://quassel-irc.org/,quasselcore}, the backend 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: 831b94a1efcea8f793afc949b5123a6235c9bb1a -- 2.47.1