Subject: [bug#42899] [PATCH v6 1/3] gnu: dovecot: Set moduledir to global directory.

From: Alexey Abramov <[email-masked]>
Date: Thu, 21 Nov 2024 12:25:56 +0000

* gnu/packages/mail.scm (dovecot)[arguments]: Add configure-flag to set
moduledir. Adjust custom 'install phase to override moduledir so it
successfully installs.
---
 gnu/packages/mail.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 636961aae79..1c537b70a27 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -2141,7 +2141,8 @@ (define-public dovecot
      `(#:configure-flags '("--sysconfdir=/etc"
                            "--localstatedir=/var"
                            "--with-sqlite"  ; not auto-detected
-                           "--with-lucene") ; not auto-detected
+                           "--with-lucene"
+                           "--with-moduledir=/usr/lib/dovecot") ; not auto-detected
        ;; The -rdynamic linker flag is needed for the backtrace() function to
        ;; have symbol names rather than just addresses.  Dovecot's tests rely
        ;; on this, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=962630.
@@ -2161,9 +2162,12 @@ (define-public dovecot
                                 "src/lib-smtp/test-bin/sendmail-success.sh")
                (("cat") (which "cat")))))
          (replace 'install
-           (lambda* (#:key make-flags #:allow-other-keys)
+           (lambda* (#:key outputs make-flags #:allow-other-keys)
+             ;; The .la files don't like having the moduledir moved.
+             (for-each delete-file (find-files "." "\\.la"))
              ;; Simple hack to avoid installing a trivial README in /etc.
              (apply invoke "make" "install" "sysconfdir=/tmp/bogus"
+                    (string-append "moduledir=" (assoc-ref outputs "out") "/lib/dovecot")
                     make-flags))))))
     (home-page "https://www.dovecot.org")
     (synopsis "Secure POP3/IMAP server")
-- 
2.46.0