summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi69
-rw-r--r--gnu/services/messaging.scm84
2 files changed, 152 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index d59a710e567..0db590aa5f7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33087,6 +33087,75 @@ strings, see
33087 33087
33088@end deftp 33088@end deftp
33089 33089
33090@subsubheading Zulip IRC bridge Service
33091
33092@cindex IRC, bridge to Zulip
33093@cindex Zulip, bridge to IRC
33094@url{https://zulip.com/integrations/irc, Zulip IRC integration} is a
33095Zulip extension to bridge @acronym{IRC, Internet Relay Chat} room to a
33096stream in the Zulip messaging system.
33097
33098@defvar zulip-irc-bridge-service-type
33099This is the service type for the Zulip IRC bridge. Its value is a
33100@code{zulip-irc-bridge-configuration} configuration instance, which is
33101documented below.
33102
33103The following example configures a Zulip integration to bridge an IRC
33104room to a Zulip stream.
33105
33106@lisp
33107(operating-system
33108
33109 ;; @dots{}
33110
33111 (services
33112 (list @dots{}
33113 (service zulip-irc-bridge-service-type
33114 (zulip-irc-bridge-configuration
33115 (irc-server "irc.example.chat")
33116 (channel "#example")
33117 (nick-prefix "irc_mirror")
33118 (stream "test here")
33119 (site "https://example.zulipchat.com")
33120 (user "irc-bot@@example.zulipchat.com")
33121 (api-key "cabba9ecabba9ecabba9ecabba9ecabb"))))))
33122@end lisp
33123
33124@end defvar
33125
33126@c %end of fragment
33127
33128@deftp {Data Type} zulip-irc-bridge-configuration
33129Available @code{zulip-irc-bridge-configuration} fields are:
33130
33131@table @asis
33132@item @code{irc-mirror} (default: @code{(file-append python-zulip "/share/zulip/integrations/bridge_with_irc/irc-mirror.py")}) (type: file-like)
33133Path to IRC mirror integration to use for the service.
33134
33135@item @code{irc-server} (type: string)
33136The IRC server where to search the room to mirror.
33137
33138@item @code{channel} (type: string)
33139The Zulip where to store the topic where IRC will be mirrored.
33140
33141@item @code{nick-prefix} (type: string)
33142Bot nickname.
33143
33144@item @code{stream} (type: string)
33145The Zulip stream/topic where the mirroring takes place.
33146
33147@item @code{site} (type: string)
33148The Zulip server that the IRC bridge integration should operate on.
33149
33150@item @code{user} (type: string)
33151The Zulip bot email that the IRC integration service should use.
33152
33153@item @code{api-key} (type: string)
33154The API key of the Zulip bot that will send the mirrored messages.
33155
33156@end table
33157
33158@end deftp
33090 33159
33091@c %end of fragment 33160@c %end of fragment
33092 33161
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index f0f1c5ee18d..017c4048250 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -28,6 +28,7 @@
28 #:use-module (gnu packages base) 28 #:use-module (gnu packages base)
29 #:use-module (gnu packages irc) 29 #:use-module (gnu packages irc)
30 #:use-module (gnu packages messaging) 30 #:use-module (gnu packages messaging)
31 #:use-module (gnu packages python)
31 #:autoload (gnu packages rust-apps) (mollysocket) 32 #:autoload (gnu packages rust-apps) (mollysocket)
32 #:use-module (gnu packages tls) 33 #:use-module (gnu packages tls)
33 #:use-module (gnu services) 34 #:use-module (gnu services)
@@ -248,7 +249,10 @@
248 soju-accounts 249 soju-accounts
249 soju-shepherd-services 250 soju-shepherd-services
250 251
251 soju-service-type)) 252 soju-service-type
253
254 zulip-irc-bridge-configuration
255 zulip-irc-bridge-service-type))
252 256
253;;; Commentary: 257;;; Commentary:
254;;; 258;;;
@@ -2725,3 +2729,81 @@ point to different things after a reload, such as renewed TLS certificates.")
2725 (service-extension account-service-type 2729 (service-extension account-service-type
2726 soju-accounts))) 2730 soju-accounts)))
2727 (description "Run the soju IRC bouncer."))) 2731 (description "Run the soju IRC bouncer.")))
2732
2733
2734;;;
2735;;; Zulip.
2736;;;
2737
2738(define-record-type* <zulip-irc-bridge-configuration>
2739 zulip-irc-bridge-configuration make-zulip-irc-bridge-configuration
2740 zulip-irc-bridge-configuration?
2741 (irc-mirror zulip-irc-bridge-mirror
2742 (default (file-append python-zulip "/bin/zulip-irc-bridge")))
2743 (irc-server zulip-irc-bridge-server)
2744 (channel zulip-irc-bridge-channel)
2745 (nick-prefix zulip-irc-bridge-nick-prefix)
2746 (stream zulip-irc-bridge-stream)
2747 (topic zulip-irc-bridge-topic
2748 (default #f))
2749 (site zulip-irc-bridge-site)
2750 (user zulip-irc-bridge-user)
2751 (api-key zulip-irc-bridge-api-key))
2752
2753(define %zulip-accounts
2754 (list (user-group
2755 (name "zulip")
2756 (system? #t))
2757 (user-account
2758 (name "zulip")
2759 (group "zulip")
2760 (system? #t)
2761 (comment "Kanata daemon user")
2762 (home-directory "/var/empty")
2763 (create-home-directory? #f)
2764 (shell (file-append shadow "/sbin/nologin")))))
2765
2766(define (zulip-irc-bridge-services config)
2767 "Return a <shepherd-service> for Zulip irc-mirror with CONFIG."
2768 (match-record config <zulip-irc-bridge-configuration>
2769 (irc-mirror irc-server channel nick-prefix stream topic site user api-key)
2770 (let* ((command (cons* irc-mirror
2771 (string-append "--irc-server=" irc-server)
2772 (string-append "--channel=" channel)
2773 (string-append "--nick-prefix=" nick-prefix)
2774 (string-append "--stream=" stream)
2775 (string-append "--site=" site)
2776 (string-append "--user=" user)
2777 (string-append "--api-key=" api-key)
2778 (if topic
2779 (list (string-append "--topic=" topic))
2780 '())))
2781 (log-file "/var/log/zulip-irc-bridge.log"))
2782 (list (shepherd-service
2783 (documentation "Run the Zulip IRC mirror.")
2784 (requirement '(user-processes networking))
2785 (provision '(zulip-irc-bridge))
2786
2787 ;; The bridge attempts to connect to IRC but might fail if
2788 ;; networking is not up. To work around that, retry slowly upon
2789 ;; failure and adjust the respawn limit accordingly.
2790 (respawn-delay 5)
2791 (respawn-limit #~'(5 . 60))
2792
2793 (start #~(make-forkexec-constructor '#$command
2794 #:log-file #$log-file
2795 #:user "zulip"
2796 #:group "zulip"))
2797 (stop #~(make-kill-destructor)))))))
2798
2799(define zulip-irc-bridge-service-type
2800 (service-type
2801 (name 'zulip)
2802 (extensions
2803 (list (service-extension account-service-type
2804 (const %zulip-accounts))
2805 (service-extension shepherd-root-service-type
2806 zulip-irc-bridge-services)))
2807 (description
2808 "Install and configure the Zulip @acronym{IRC, Internet Relay Chat} bridge
2809as a Shepherd service.")))