guix_mirror_bot pushed a commit to branch master
in repository guix.
commit b0231ab7ee89c1dd1e4024d2ececd825cb68e20d
Author: Sergio Pastor Pérez <[email protected]>
AuthorDate: Tue Mar 10 16:21:26 2026 +0100
services: Add `zulip-irc-bridge-service-type'.
* gnu/services/messaging.scm: (zulip-irc-bridge-configuration): New
configuration record.
(%zulip-accounts): New variable.
(zulip-irc-bridge-services): New procedure.
(zulip-irc-bridge-service-type): New service.
* doc/guix.texi (Messaging Services): Document
`zulip-irc-bridge-service-type'
and `zulip-irc-bridge-configuration'.
Change-Id: Ie74aa71f2912ccd905c0866ede9ead7b397f7c64
Signed-off-by: Ludovic Courtès <[email protected]>
Modified-by: Ludovic Courtès <[email protected]>
Merges: #7047
---
doc/guix.texi | 69 +++++++++++++++++++++++++++++++++++++
gnu/services/messaging.scm | 84 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 152 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index d59a710e56..0db590aa5f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33087,6 +33087,75 @@ strings, see
@end deftp
+@subsubheading Zulip IRC bridge Service
+
+@cindex IRC, bridge to Zulip
+@cindex Zulip, bridge to IRC
+@url{https://zulip.com/integrations/irc, Zulip IRC integration} is a
+Zulip extension to bridge @acronym{IRC, Internet Relay Chat} room to a
+stream in the Zulip messaging system.
+
+@defvar zulip-irc-bridge-service-type
+This is the service type for the Zulip IRC bridge. Its value is a
+@code{zulip-irc-bridge-configuration} configuration instance, which is
+documented below.
+
+The following example configures a Zulip integration to bridge an IRC
+room to a Zulip stream.
+
+@lisp
+(operating-system
+
+ ;; @dots{}
+
+ (services
+ (list @dots{}
+ (service zulip-irc-bridge-service-type
+ (zulip-irc-bridge-configuration
+ (irc-server "irc.example.chat")
+ (channel "#example")
+ (nick-prefix "irc_mirror")
+ (stream "test here")
+ (site "https://example.zulipchat.com")
+ (user "irc-bot@@example.zulipchat.com")
+ (api-key "cabba9ecabba9ecabba9ecabba9ecabb"))))))
+@end lisp
+
+@end defvar
+
+@c %end of fragment
+
+@deftp {Data Type} zulip-irc-bridge-configuration
+Available @code{zulip-irc-bridge-configuration} fields are:
+
+@table @asis
+@item @code{irc-mirror} (default: @code{(file-append python-zulip
"/share/zulip/integrations/bridge_with_irc/irc-mirror.py")}) (type: file-like)
+Path to IRC mirror integration to use for the service.
+
+@item @code{irc-server} (type: string)
+The IRC server where to search the room to mirror.
+
+@item @code{channel} (type: string)
+The Zulip where to store the topic where IRC will be mirrored.
+
+@item @code{nick-prefix} (type: string)
+Bot nickname.
+
+@item @code{stream} (type: string)
+The Zulip stream/topic where the mirroring takes place.
+
+@item @code{site} (type: string)
+The Zulip server that the IRC bridge integration should operate on.
+
+@item @code{user} (type: string)
+The Zulip bot email that the IRC integration service should use.
+
+@item @code{api-key} (type: string)
+The API key of the Zulip bot that will send the mirrored messages.
+
+@end table
+
+@end deftp
@c %end of fragment
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index f0f1c5ee18..017c404825 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -28,6 +28,7 @@
#:use-module (gnu packages base)
#:use-module (gnu packages irc)
#:use-module (gnu packages messaging)
+ #:use-module (gnu packages python)
#:autoload (gnu packages rust-apps) (mollysocket)
#:use-module (gnu packages tls)
#:use-module (gnu services)
@@ -248,7 +249,10 @@
soju-accounts
soju-shepherd-services
- soju-service-type))
+ soju-service-type
+
+ zulip-irc-bridge-configuration
+ zulip-irc-bridge-service-type))
;;; Commentary:
;;;
@@ -2725,3 +2729,81 @@ point to different things after a reload, such as
renewed TLS certificates.")
(service-extension account-service-type
soju-accounts)))
(description "Run the soju IRC bouncer.")))
+
+
+;;;
+;;; Zulip.
+;;;
+
+(define-record-type* <zulip-irc-bridge-configuration>
+ zulip-irc-bridge-configuration make-zulip-irc-bridge-configuration
+ zulip-irc-bridge-configuration?
+ (irc-mirror zulip-irc-bridge-mirror
+ (default (file-append python-zulip "/bin/zulip-irc-bridge")))
+ (irc-server zulip-irc-bridge-server)
+ (channel zulip-irc-bridge-channel)
+ (nick-prefix zulip-irc-bridge-nick-prefix)
+ (stream zulip-irc-bridge-stream)
+ (topic zulip-irc-bridge-topic
+ (default #f))
+ (site zulip-irc-bridge-site)
+ (user zulip-irc-bridge-user)
+ (api-key zulip-irc-bridge-api-key))
+
+(define %zulip-accounts
+ (list (user-group
+ (name "zulip")
+ (system? #t))
+ (user-account
+ (name "zulip")
+ (group "zulip")
+ (system? #t)
+ (comment "Kanata daemon user")
+ (home-directory "/var/empty")
+ (create-home-directory? #f)
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define (zulip-irc-bridge-services config)
+ "Return a <shepherd-service> for Zulip irc-mirror with CONFIG."
+ (match-record config <zulip-irc-bridge-configuration>
+ (irc-mirror irc-server channel nick-prefix stream topic site
user api-key)
+ (let* ((command (cons* irc-mirror
+ (string-append "--irc-server=" irc-server)
+ (string-append "--channel=" channel)
+ (string-append "--nick-prefix=" nick-prefix)
+ (string-append "--stream=" stream)
+ (string-append "--site=" site)
+ (string-append "--user=" user)
+ (string-append "--api-key=" api-key)
+ (if topic
+ (list (string-append "--topic=" topic))
+ '())))
+ (log-file "/var/log/zulip-irc-bridge.log"))
+ (list (shepherd-service
+ (documentation "Run the Zulip IRC mirror.")
+ (requirement '(user-processes networking))
+ (provision '(zulip-irc-bridge))
+
+ ;; The bridge attempts to connect to IRC but might fail if
+ ;; networking is not up. To work around that, retry slowly upon
+ ;; failure and adjust the respawn limit accordingly.
+ (respawn-delay 5)
+ (respawn-limit #~'(5 . 60))
+
+ (start #~(make-forkexec-constructor '#$command
+ #:log-file #$log-file
+ #:user "zulip"
+ #:group "zulip"))
+ (stop #~(make-kill-destructor)))))))
+
+(define zulip-irc-bridge-service-type
+ (service-type
+ (name 'zulip)
+ (extensions
+ (list (service-extension account-service-type
+ (const %zulip-accounts))
+ (service-extension shepherd-root-service-type
+ zulip-irc-bridge-services)))
+ (description
+ "Install and configure the Zulip @acronym{IRC, Internet Relay Chat} bridge
+as a Shepherd service.")))