From b4db11364185e035de3d8c335b1a66eddeeeb84c Mon Sep 17 00:00:00 2001 From: Jonathan Brielmaier Date: Sat, 5 Dec 2020 01:09:13 +0100 Subject: services: Add radicale-service-type. * gnu/services/mail.scm (radicale-configuration) (radicale-configuration?): New procedures. (%default-radicale-config-file) (radicale-service-type): New variables. * doc/guix.texi: Document it. --- gnu/services/mail.scm | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'gnu/services/mail.scm') diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 71fa975b5d..c0f6371104 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017 Carlo Zancanaro ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019 Kristofer Buffington +;;; Copyright © 2020 Jonathan Brielmaier ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (gnu system shadow) #:use-module (gnu packages mail) #:use-module (gnu packages admin) + #:use-module (gnu packages dav) #:use-module (gnu packages tls) #:use-module (guix records) #:use-module (guix packages) @@ -70,7 +72,12 @@ imap4d-configuration imap4d-configuration? imap4d-service-type - %default-imap4d-config-file)) + %default-imap4d-config-file + + radicale-configuration + radicale-configuration? + radicale-service-type + %default-radicale-config-file)) ;;; Commentary: ;;; @@ -1834,3 +1841,75 @@ exim_group = exim (list (service-extension shepherd-root-service-type imap4d-shepherd-service))) (default-value (imap4d-configuration)))) + + +;;; +;;; Radicale. +;;; + +(define-record-type* + radicale-configuration make-radicale-configuration + radicale-configuration? + (package radicale-configuration-package + (default radicale)) + (config-file radicale-configuration-config-file + (default %default-radicale-config-file))) + +(define %default-radicale-config-file + (plain-file "radicale.conf" " +[auth] +type = htpasswd +htpasswd_filename = /var/lib/radicale/users +htpasswd_encryption = plain + +[server] +hosts = localhost:5232")) + +(define %radicale-accounts + (list (user-group + (name "radicale") + (system? #t)) + (user-account + (name "radicale") + (group "radicale") + (system? #t) + (comment "Radicale Daemon") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define radicale-shepherd-service + (match-lambda + (($ package config-file) + (list (shepherd-service + (provision '(radicale)) + (documentation "Run the radicale daemon.") + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/radicale") + "-C" #$config-file) + #:user "radicale" + #:group "radicale")) + (stop #~(make-kill-destructor))))))) + +(define radicale-activation + (match-lambda + (($ package config-file) + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((uid (passwd:uid (getpw "radicale"))) + (gid (group:gid (getgr "radicale")))) + (mkdir-p "/var/lib/radicale/collections") + (chown "/var/lib/radicale" uid gid) + (chown "/var/lib/radicale/collections" uid gid) + (chmod "/var/lib/radicale" #o700))))))) + +(define radicale-service-type + (service-type + (name 'radicale) + (description "Run radicale, a small CalDAV and CardDAV server.") + (extensions + (list (service-extension shepherd-root-service-type radicale-shepherd-service) + (service-extension account-service-type (const %radicale-accounts)) + (service-extension activation-service-type radicale-activation))) + (default-value (radicale-configuration)))) -- cgit 1.4.1