Subject: [PATCH v4 4/4] gnu: Add mailctl.

From: pinoaffe <[email-masked]>
Date: Tue, 24 Oct 2023 11:24:08 +0200

* gnu/packages/mail.scm (mailctl): New variable.
---
 gnu/packages/mail.scm | 58 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 9f410047e2..78bff0546c 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -54,6 +54,7 @@
 ;;; Copyright © 2023 Timo Wilken <[email-masked]>
 ;;; Copyright © 2023 Arjan Adriaanse <[email-masked]>
 ;;; Copyright © 2023 Wilko Meyer <[email-masked]>
+;;; Copyright © 2023 pinoaffe <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -115,6 +116,7 @@ (define-module (gnu packages mail)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages guile-xyz)
   #:use-module (gnu packages haskell-xyz)
+  #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages kerberos)
   #:use-module (gnu packages language)
@@ -179,6 +181,7 @@ (define-module (gnu packages mail)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system guile)
+  #:use-module (guix build-system haskell)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system pyproject)
@@ -1148,6 +1151,61 @@ (define-public offlineimap3
 (define-public offlineimap
   (deprecated-package "offlineimap" offlineimap3))
 
+(define-public mailctl
+  (package
+   (name "mailctl")
+   (version "0.9.1")
+   (source (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://github.com/pdobsan/mailctl")
+                  (commit version)))
+            (file-name (git-file-name name version))
+            (sha256
+             (base32
+              "18mjlvf8h0afirlr2pw30p9cpcyhfw4g41c0liqbsan684cj3dk1"))))
+   (build-system haskell-build-system)
+   (home-page "https://github.com/pdobsan/mailctl")
+   (arguments `(#:phases (modify-phases %standard-phases
+                           ;; The mailctl.cabal file specifies a minimum cabal
+                           ;; version of 3.8 (which is newer than the cabal
+                           ;; packaged in guix), but doesn't use any new
+                           ;; features and it builds with 3.6.
+                           (add-after 'unpack 'patch-cabal-version
+                             (lambda _
+                               (substitute* "mailctl.cabal"
+                                 (("3.8") "3.6")))))))
+   (inputs (list ghc-aeson
+                 ghc-hsyslog
+                 ghc-http-conduit
+                 ghc-network-uri
+                 ghc-optparse-applicative
+                 ghc-pretty-simple
+                 ghc-twain
+                 ghc-base64
+                 ghc-strings
+                 ghc-utf8-string
+                 ghc-warp
+                 ghc-yaml))
+   (synopsis "Authorize and renew OAuth2 credentials for IMAP/SMTP clients")
+   (description "@code{mailctl} provides IMAP/SMTP clients with the
+capabilities of renewal and authorization of OAuth2 credentials.
+
+Many IMAP/SMTP clients, like @code{offlineimap}, @code{msmtp}, @code{fdm},
+@code{isync}, @code{neomutt} or @code{mutt} can use OAuth2 access tokens but
+lack the ability to renew and/or authorize OAuth2 credentials.  The purpose of
+@code{mailctl} is to provide these missing capabilities by acting as a kind of
+smart password manager.  In particular, access token renewal happens
+automatically in the background transparent to the user.
+
+If an IMAP/SMTP client cannot use an OAuth2 access token itself it may be
+\"wrapped\" with @code{fdm} and @code{msmtp} with the help of @code{mailctl}.
+
+@code{mailctl} also has some functionalities to manage the orchestration of a
+mailing system comprised of @code{msmtp}, @code{fdm}, and @code{mutt} or
+similar ones.")
+   (license license:bsd-3)))
+
 (define-public emacs-mew
   (let ((commit "35772ee0b44dd7e56b0f3899b27fa545b2bc6f03")
         (revision "1"))
-- 
2.41.0