summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Abramov via Guix-patches via <guix-patches@gnu.org>2024-11-21 12:25:57 +0000
committerChristopher Baines <mail@cbaines.net>2025-02-25 10:57:51 +0000
commitf83b91a4ee6fab2ac595bccdf3fb7151a8dcc69c (patch)
tree98b50c0c02a35d0c33d486152e45e9d8fd08fbb4
parent81e99a5caae91dcedff182bad008a2c815924ae7 (diff)
services: dovecot: Provide plugins through a /gnu/store directory.
* gnu/services/mail.scm (package-list?, serialize-package-list): New procedures. * gnu/services/mail.scm (dovecot-configuration)[extensions]: New field. The field lets you provide a list of dovecot plugins that need to be available during the runtime. A union of the set of modules will be created on the activation time. * gnu/services/mail.scm (opaque-dovecot-configuration)[extensions]: Likewise. * gnu/services/mail.scm (make-dovecot-moduledir): New function. * gnu/services/mail.scm (%dovecot-activation): Add step to compute a set of modules, and provide them over the shared link at /usr/lib/dovecot. * doc/guix.texi (Mail Services)[extension]: Add documentation. Clarify the purpose and usage of the extensions parameter. Add an example showing how to enable Sieve filtering using dovecot-pigeonhole. Better explain the module directory structure and requirements. Change-Id: I3c3955bb04b09d245242112f6810ecc0558109a1 Signed-off-by: Christopher Baines <mail@cbaines.net>
-rw-r--r--doc/guix.texi19
-rw-r--r--gnu/services/mail.scm44
2 files changed, 61 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index b525913c151..a036c85c31a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -27484,6 +27484,25 @@ Available @code{dovecot-configuration} fields are:
27484The dovecot package. 27484The dovecot package.
27485@end deftypevr 27485@end deftypevr
27486 27486
27487@deftypevr {@code{dovecot-configuration} parameter} package-list extensions
27488A list of additional Dovecot plugin packages to make available at runtime. During
27489service activation, the @file{lib/dovecot} directory from each specified package
27490is combined with Dovecot's core modules into a unified module directory.
27491
27492For example, to enable Sieve filtering:
27493
27494@lisp
27495(extensions (list dovecot-pigeonhole))
27496@end lisp
27497
27498Each package in the list must provide its modules at @file{lib/dovecot},
27499as this is where @code{make-dovecot-moduledir} expects to find its
27500extensions. The service combines these directories to create a unified
27501module structure.
27502
27503The default value is an empty list, providing only core Dovecot functionality.
27504@end deftypevr
27505
27487@deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen 27506@deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
27488A list of IPs or hosts where to listen for connections. @samp{*} 27507A list of IPs or hosts where to listen for connections. @samp{*}
27489listens on all IPv4 interfaces, @samp{::} listens on all IPv6 27508listens on all IPv4 interfaces, @samp{::} listens on all IPv6
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 4ab0d681348..b9a61163d56 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -521,11 +521,21 @@ as @code{#t}.)")
521 (serialize-namespace-configuration field-name val)) 521 (serialize-namespace-configuration field-name val))
522 val)) 522 val))
523 523
524(define (package-list? val)
525 (and (list? val) (and-map package? val)))
526(define (serialize-package-list field-name val)
527 #f)
528
524(define-configuration dovecot-configuration 529(define-configuration dovecot-configuration
525 (dovecot 530 (dovecot
526 (file-like dovecot) 531 (file-like dovecot)
527 "The dovecot package.") 532 "The dovecot package.")
528 533
534 (extensions
535 (package-list '())
536 "Plugins and extensions to the Dovecot package. Specify a list of dovecot
537plugins that needs to be available for dovecot and its modules.")
538
529 (listen 539 (listen
530 (comma-separated-string-list '("*" "::")) 540 (comma-separated-string-list '("*" "::"))
531 "A list of IPs or hosts where to listen in for connections. @samp{*} 541 "A list of IPs or hosts where to listen in for connections. @samp{*}
@@ -1109,7 +1119,7 @@ isn't enough disk space, just skip it.
1109@item fcntl 1119@item fcntl
1110Use this if possible. Works with NFS too if lockd is used. 1120Use this if possible. Works with NFS too if lockd is used.
1111@item flock 1121@item flock
1112May not exist in all systems. Doesn't work with NFS. 1122May not exist in all systems. Doesn't work with NFS.
1113@item lockf 1123@item lockf
1114May not exist in all systems. Doesn't work with NFS. 1124May not exist in all systems. Doesn't work with NFS.
1115@end table 1125@end table
@@ -1500,6 +1510,11 @@ greyed out, instead of only later giving \"not selectable\" popup error.
1500 (file-like dovecot) 1510 (file-like dovecot)
1501 "The dovecot package.") 1511 "The dovecot package.")
1502 1512
1513 (extensions
1514 (package-list '())
1515 "Plugins and extensions to the Dovecot package. Specify a list of dovecot
1516plugins that needs to be available for dovecot and its modules.")
1517
1503 (string 1518 (string
1504 (string (configuration-missing-field 'opaque-dovecot-configuration 1519 (string (configuration-missing-field 'opaque-dovecot-configuration
1505 'string)) 1520 'string))
@@ -1525,6 +1540,21 @@ greyed out, instead of only later giving \"not selectable\" popup error.
1525 (home-directory "/var/empty") 1540 (home-directory "/var/empty")
1526 (shell (file-append shadow "/sbin/nologin"))))) 1541 (shell (file-append shadow "/sbin/nologin")))))
1527 1542
1543(define (make-dovecot-moduledir packages)
1544 "Return a computed file containing a union of Dovecot module directories from PACKAGES.
1545Each package's '/lib/dovecot' directory is combined into a single location."
1546 ;; Create a union of the set of modules and dovecot itself.
1547 (with-imported-modules '((guix build union))
1548 (computed-file
1549 "dovecot-moduledir"
1550 #~(begin
1551 (use-modules (guix build union) (srfi srfi-26))
1552
1553 (union-build #$output
1554 (map (cut string-append <>
1555 "/lib/dovecot")
1556 (list #$@packages)))))))
1557
1528(define (%dovecot-activation config) 1558(define (%dovecot-activation config)
1529 ;; Activation gexp. 1559 ;; Activation gexp.
1530 (let ((config-str 1560 (let ((config-str
@@ -1535,7 +1565,15 @@ greyed out, instead of only later giving \"not selectable\" popup error.
1535 (with-output-to-string 1565 (with-output-to-string
1536 (lambda () 1566 (lambda ()
1537 (serialize-configuration config 1567 (serialize-configuration config
1538 dovecot-configuration-fields))))))) 1568 dovecot-configuration-fields))))))
1569 (moduledir-directory
1570 (cond
1571 ((opaque-dovecot-configuration? config)
1572 (make-dovecot-moduledir (cons* (opaque-dovecot-configuration-dovecot config)
1573 (opaque-dovecot-configuration-extensions config))))
1574 (else
1575 (make-dovecot-moduledir (cons* (dovecot-configuration-dovecot config)
1576 (dovecot-configuration-extensions config)))))))
1539 (with-imported-modules (source-module-closure '((gnu build activation))) 1577 (with-imported-modules (source-module-closure '((gnu build activation)))
1540 #~(begin 1578 #~(begin
1541 (use-modules (guix build utils) (gnu build activation)) 1579 (use-modules (guix build utils) (gnu build activation))
@@ -1586,6 +1624,8 @@ greyed out, instead of only later giving \"not selectable\" popup error.
1586 (copy-file #$(plain-file "dovecot.conf" config-str) 1624 (copy-file #$(plain-file "dovecot.conf" config-str)
1587 "/etc/dovecot/dovecot.conf") 1625 "/etc/dovecot/dovecot.conf")
1588 (mkdir-p/perms "/etc/dovecot/private" user #o700) 1626 (mkdir-p/perms "/etc/dovecot/private" user #o700)
1627 (mkdir-p "/usr/lib")
1628 (switch-symlinks "/usr/lib/dovecot" #$moduledir-directory)
1589 (create-self-signed-certificate-if-absent 1629 (create-self-signed-certificate-if-absent
1590 #:private-key "/etc/dovecot/private/default.pem" 1630 #:private-key "/etc/dovecot/private/default.pem"
1591 #:public-key "/etc/dovecot/default.pem" 1631 #:public-key "/etc/dovecot/default.pem"