summaryrefslogtreecommitdiff
path: root/gnu/services/messaging.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-15 22:04:55 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-15 23:29:33 +0100
commitf2bee4210ff7da38696d8e49999282e27b4a6364 (patch)
tree8bba5d23531ffdfefeba7b60e2f6046d04eaaf9c /gnu/services/messaging.scm
parent95aa64bc48cae061effafa7675ea9d9ccbe311a4 (diff)
services: bitlbee: Move to (gnu services messaging).
* gnu/services/networking.scm (<bitlbee-configuration>) (bitlbee-shepherd-service, %bitlbee-accounts, %bitlbee-activation) (bitlbee-service-type, bitlbee-service): Move to... * gnu/services/messaging.scm: ... here. * doc/guix.texi (Networking Services): Move 'bitlbee-service' doc to... (Messaging Services): ... here.
Diffstat (limited to 'gnu/services/messaging.scm')
-rw-r--r--gnu/services/messaging.scm117
1 files changed, 116 insertions, 1 deletions
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index a9820ed21ff..c0ccdbad335 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org> 2;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
4;;; Copyright © 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -25,6 +26,7 @@
25 #:use-module (gnu services configuration) 26 #:use-module (gnu services configuration)
26 #:use-module (gnu system shadow) 27 #:use-module (gnu system shadow)
27 #:use-module (guix gexp) 28 #:use-module (guix gexp)
29 #:use-module (guix modules)
28 #:use-module (guix records) 30 #:use-module (guix records)
29 #:use-module (guix packages) 31 #:use-module (guix packages)
30 #:use-module (srfi srfi-1) 32 #:use-module (srfi srfi-1)
@@ -42,7 +44,12 @@
42 ssl-configuration 44 ssl-configuration
43 45
44 %default-modules-enabled 46 %default-modules-enabled
45 prosody-configuration-pidfile)) 47 prosody-configuration-pidfile
48
49 bitlbee-configuration
50 bitlbee-configuration?
51 bitlbee-service
52 bitlbee-service-type))
46 53
47;;; Commentary: 54;;; Commentary:
48;;; 55;;;
@@ -751,3 +758,111 @@ string, you could instantiate a prosody service like this:
751 (opaque-prosody-configuration 758 (opaque-prosody-configuration
752 (prosody.cfg.lua \"\"))) 759 (prosody.cfg.lua \"\")))
753@end example")) 760@end example"))
761
762
763;;;
764;;; BitlBee.
765;;;
766
767(define-record-type* <bitlbee-configuration>
768 bitlbee-configuration make-bitlbee-configuration
769 bitlbee-configuration?
770 (bitlbee bitlbee-configuration-bitlbee
771 (default bitlbee))
772 (interface bitlbee-configuration-interface
773 (default "127.0.0.1"))
774 (port bitlbee-configuration-port
775 (default 6667))
776 (extra-settings bitlbee-configuration-extra-settings
777 (default "")))
778
779(define bitlbee-shepherd-service
780 (match-lambda
781 (($ <bitlbee-configuration> bitlbee interface port extra-settings)
782 (let ((conf (plain-file "bitlbee.conf"
783 (string-append "
784 [settings]
785 User = bitlbee
786 ConfigDir = /var/lib/bitlbee
787 DaemonInterface = " interface "
788 DaemonPort = " (number->string port) "
789" extra-settings))))
790
791 (with-imported-modules (source-module-closure
792 '((gnu build shepherd)
793 (gnu system file-systems)))
794 (list (shepherd-service
795 (provision '(bitlbee))
796
797 ;; Note: If networking is not up, then /etc/resolv.conf
798 ;; doesn't get mapped in the container, hence the dependency
799 ;; on 'networking'.
800 (requirement '(user-processes networking))
801
802 (modules '((gnu build shepherd)
803 (gnu system file-systems)))
804 (start #~(make-forkexec-constructor/container
805 (list #$(file-append bitlbee "/sbin/bitlbee")
806 "-n" "-F" "-u" "bitlbee" "-c" #$conf)
807
808 #:pid-file "/var/run/bitlbee.pid"
809 #:mappings (list (file-system-mapping
810 (source "/var/lib/bitlbee")
811 (target source)
812 (writable? #t)))))
813 (stop #~(make-kill-destructor)))))))))
814
815(define %bitlbee-accounts
816 ;; User group and account to run BitlBee.
817 (list (user-group (name "bitlbee") (system? #t))
818 (user-account
819 (name "bitlbee")
820 (group "bitlbee")
821 (system? #t)
822 (comment "BitlBee daemon user")
823 (home-directory "/var/empty")
824 (shell (file-append shadow "/sbin/nologin")))))
825
826(define %bitlbee-activation
827 ;; Activation gexp for BitlBee.
828 #~(begin
829 (use-modules (guix build utils))
830
831 ;; This directory is used to store OTR data.
832 (mkdir-p "/var/lib/bitlbee")
833 (let ((user (getpwnam "bitlbee")))
834 (chown "/var/lib/bitlbee"
835 (passwd:uid user) (passwd:gid user)))))
836
837(define bitlbee-service-type
838 (service-type (name 'bitlbee)
839 (extensions
840 (list (service-extension shepherd-root-service-type
841 bitlbee-shepherd-service)
842 (service-extension account-service-type
843 (const %bitlbee-accounts))
844 (service-extension activation-service-type
845 (const %bitlbee-activation))))
846 (default-value (bitlbee-configuration))
847 (description
848 "Run @url{http://bitlbee.org,BitlBee}, a daemon that acts as
849a gateway between IRC and chat networks.")))
850
851(define* (bitlbee-service #:key (bitlbee bitlbee)
852 (interface "127.0.0.1") (port 6667)
853 (extra-settings ""))
854 "Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
855acts as a gateway between IRC and chat networks.
856
857The daemon will listen to the interface corresponding to the IP address
858specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only
859local clients can connect, whereas @code{0.0.0.0} means that connections can
860come from any networking interface.
861
862In addition, @var{extra-settings} specifies a string to append to the
863configuration file."
864 (service bitlbee-service-type
865 (bitlbee-configuration
866 (bitlbee bitlbee)
867 (interface interface) (port port)
868 (extra-settings extra-settings))))