diff options
| author | Sergio Pastor Pérez <sergio.pastor-perez@inria.fr> | 2026-03-10 16:21:26 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-07-25 01:30:26 +0200 |
| commit | b0231ab7ee89c1dd1e4024d2ececd825cb68e20d (patch) | |
| tree | e8cbb40b35c05aa0f794972c2cf3cf50fc2df6a8 /gnu | |
| parent | b0d7a62276777b913331ea056bef5ad5ba1e0496 (diff) | |
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 <ludo@gnu.org>
Modified-by: Ludovic Courtès <ludo@gnu.org>
Merges: #7047
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/messaging.scm | 84 |
1 files changed, 83 insertions, 1 deletions
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 | ||
| 2809 | as a Shepherd service."))) | ||
