diff options
| author | Evgeny Pisemsky <mail@pisemsky.site> | 2025-05-09 19:46:49 +0200 |
|---|---|---|
| committer | Danny Milosavljevic <dannym@friendly-machines.com> | 2025-05-09 19:47:24 +0200 |
| commit | 44d178265c23834a6050de06863cd0fcde64e4f8 (patch) | |
| tree | 4b94e560790e09ea5400af79d36f3753fbf0eb94 /gnu | |
| parent | 2258b5f5b4733553d6dc3983e6678837104a0647 (diff) | |
services: Add mosquitto-service-type.
* gnu/services/messaging.scm (<mosquitto-configuration>): 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: I3500c5b6b69084c1f4a6da66ea45bfd42c871f3f
Signed-off-by: Danny Milosavljevic <dannym@friendly-machines.com>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/messaging.scm | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index c13700f0326..4cfac3bc3a7 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | ;;; Copyright © 2015, 2017-2020, 2022-2024 Ludovic Courtès <ludo@gnu.org> | 4 | ;;; Copyright © 2015, 2017-2020, 2022-2024 Ludovic Courtès <ludo@gnu.org> |
| 5 | ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr> | 5 | ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr> |
| 6 | ;;; Copyright © 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com> | 6 | ;;; Copyright © 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
| 7 | ;;; Copyright © 2024 Evgeny Pisemsky <mail@pisemsky.site> | ||
| 7 | ;;; | 8 | ;;; |
| 8 | ;;; This file is part of GNU Guix. | 9 | ;;; This file is part of GNU Guix. |
| 9 | ;;; | 10 | ;;; |
| @@ -187,7 +188,15 @@ | |||
| 187 | quassel-service-type | 188 | quassel-service-type |
| 188 | 189 | ||
| 189 | snuik-configuration | 190 | snuik-configuration |
| 190 | snuik-service-type)) | 191 | snuik-service-type |
| 192 | |||
| 193 | mosquitto-configuration | ||
| 194 | mosquitto-configuration? | ||
| 195 | mosquitto-configuration-package | ||
| 196 | mosquitto-configuration-config-file | ||
| 197 | mosquitto-configuration-user | ||
| 198 | mosquitto-configuration-group | ||
| 199 | mosquitto-service-type)) | ||
| 191 | 200 | ||
| 192 | ;;; Commentary: | 201 | ;;; Commentary: |
| 193 | ;;; | 202 | ;;; |
| @@ -2107,6 +2116,67 @@ multiple machines simultaneously."))) | |||
| 2107 | 2116 | ||
| 2108 | 2117 | ||
| 2109 | ;;; | 2118 | ;;; |
| 2119 | ;;; Mosquitto. | ||
| 2120 | ;;; | ||
| 2121 | |||
| 2122 | (define-record-type* <mosquitto-configuration> | ||
| 2123 | mosquitto-configuration | ||
| 2124 | make-mosquitto-configuration | ||
| 2125 | mosquitto-configuration? | ||
| 2126 | (package mosquitto-configuration-package | ||
| 2127 | (default mosquitto)) | ||
| 2128 | (config-file mosquitto-configuration-config-file | ||
| 2129 | (default #f)) | ||
| 2130 | (user mosquitto-configuration-user | ||
| 2131 | (default "mosquitto")) | ||
| 2132 | (group mosquitto-configuration-group | ||
| 2133 | (default "mosquitto"))) | ||
| 2134 | |||
| 2135 | (define (mosquitto-accounts config) | ||
| 2136 | (match-record config <mosquitto-configuration> | ||
| 2137 | (user group) | ||
| 2138 | (filter identity | ||
| 2139 | (list | ||
| 2140 | (and (equal? group "mosquitto") | ||
| 2141 | (user-group | ||
| 2142 | (name "mosquitto") | ||
| 2143 | (system? #t))) | ||
| 2144 | (and (equal? user "mosquitto") | ||
| 2145 | (user-account | ||
| 2146 | (name "mosquitto") | ||
| 2147 | (group group) | ||
| 2148 | (system? #t) | ||
| 2149 | (comment "bzzz") | ||
| 2150 | (home-directory "/var/empty") | ||
| 2151 | (shell (file-append shadow "/sbin/nologin")))))))) | ||
| 2152 | |||
| 2153 | (define (mosquitto-shepherd-service config) | ||
| 2154 | (match-record config <mosquitto-configuration> | ||
| 2155 | (package config-file user group) | ||
| 2156 | (list (shepherd-service | ||
| 2157 | (documentation "Run the Mosquitto MQTT broker.") | ||
| 2158 | (provision '(mosquitto)) | ||
| 2159 | (requirement '(networking syslogd user-processes)) | ||
| 2160 | (start #~(make-forkexec-constructor | ||
| 2161 | (list #$(file-append package "/sbin/mosquitto") | ||
| 2162 | #$@(if config-file | ||
| 2163 | (list "-c" config-file) | ||
| 2164 | '())) | ||
| 2165 | #:user #$user | ||
| 2166 | #:group #$group)) | ||
| 2167 | (stop #~(make-kill-destructor)))))) | ||
| 2168 | |||
| 2169 | (define mosquitto-service-type | ||
| 2170 | (service-type | ||
| 2171 | (description "Run the Mosquitto MQTT broker.") | ||
| 2172 | (name 'mosquitto) | ||
| 2173 | (extensions | ||
| 2174 | (list (service-extension account-service-type mosquitto-accounts) | ||
| 2175 | (service-extension shepherd-root-service-type mosquitto-shepherd-service))) | ||
| 2176 | (default-value (mosquitto-configuration)))) | ||
| 2177 | |||
| 2178 | |||
| 2179 | ;;; | ||
| 2110 | ;;; Snuik. | 2180 | ;;; Snuik. |
| 2111 | ;;; | 2181 | ;;; |
| 2112 | (define-maybe integer (no-serialization)) | 2182 | (define-maybe integer (no-serialization)) |
