GNU logs - #66557, boring messages


Message sent to , guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
Resent-From: Nils Landt <nils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: , guix-patches@HIDDEN
Resent-Date: Sun, 15 Oct 2023 14:03:01 +0000
Resent-Message-ID: <handler.66557.B.169737855718116 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66557 <at> debbugs.gnu.org
Cc: Nils Landt <nils.landt@HIDDEN>, ( <paren@HIDDEN>, Andrew Tropin <andrew@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
X-Debbugs-Original-Xcc: ( <paren@HIDDEN>, Andrew Tropin <andrew@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.169737855718116
          (code B ref -1); Sun, 15 Oct 2023 14:03:01 +0000
Received: (at submit) by debbugs.gnu.org; 15 Oct 2023 14:02:37 +0000
Received: from localhost ([127.0.0.1]:53862 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qs1hU-0004i7-Bt
	for submit <at> debbugs.gnu.org; Sun, 15 Oct 2023 10:02:37 -0400
Received: from lists.gnu.org ([2001:470:142::17]:51600)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nils@HIDDEN>) id 1qs1hP-0004hr-R9
 for submit <at> debbugs.gnu.org; Sun, 15 Oct 2023 10:02:35 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <nils@HIDDEN>) id 1qs1gv-0000TL-Uf
 for guix-patches@HIDDEN; Sun, 15 Oct 2023 10:02:01 -0400
Received: from mout-p-202.mailbox.org ([80.241.56.172])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
 (Exim 4.90_1) (envelope-from <nils@HIDDEN>) id 1qs1ge-0007b7-7T
 for guix-patches@HIDDEN; Sun, 15 Oct 2023 10:01:50 -0400
Received: from smtp102.mailbox.org (smtp102.mailbox.org
 [IPv6:2001:67c:2050:b231:465::102])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4S7hk90pr6z9sp7;
 Sun, 15 Oct 2023 16:01:37 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landt.email; s=MBO0001;
 t=1697378497;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=P7igJAJFjkjc/e3BaAO1VNmsd+cYiDlPXeEaOTr6oCs=;
 b=G9NH3vc+VI1EoNPLA5h2qzcsSuOe3fre4DwzeN1i9nZX+kn6utc58xhF5DsxfmOSIm3k+Q
 0/lyC54yjH7G6u49MmC3M3UKIYRqrNa8bueOjHLFcxJjJy8gow8/Pf1tifcSvFLtTPrmIN
 arnu3gfdn8z0hfIup07y6IQyQZCqVVew3L7ts6lY6lNeXl+3K34GE35S/mgKQmxSXU1dJL
 mvegeh3o0ya0ZYdXvhRZQjsR8lA375Ios1bhUre7mcLR+PKt27Tj64BQATSPPUkn+WWy8O
 7ip5/LgAUHmmZ+8XcpgbzljfPuUpb/NP4LvtlbPpb4zE52gmSFpZfiiqbAndkQ==
From: Nils Landt <nils@HIDDEN>
Date: Sun, 15 Oct 2023 16:01:18 +0200
Message-ID: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-MBO-RS-META: jmr8w6kn99tujj9tjbk3bu65sfh5csr4
X-MBO-RS-ID: 7f8937042144065bde5
X-Rspamd-Queue-Id: 4S7hk90pr6z9sp7
Received-SPF: pass client-ip=80.241.56.172; envelope-from=nils@HIDDEN;
 helo=mout-p-202.mailbox.org
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

From: Nils Landt <nils.landt@HIDDEN>

* gnu/home/services/mail.scm: (home-goimapnotify-configuration,
home-goimapnotify-service-type, goimapnotify-account,
goimapnotify-tls-options): New variables.
(goimapnotify-format-field, goimapnotify-serialize-field,  goimapnotify-serialize-goimapnotify-tls-options): New procedures.
* doc/guix.texi (Mail Home Services): New node.
---
This patch adds a home service for generating goimapnotify JSON
configuration files.

I was unable to get generate-documentation working with
sub-documentation, so the configurations are documented separately.

 doc/guix.texi              | 209 +++++++++++++++++++++++++++------
 gnu/home/services/mail.scm | 234 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 406 insertions(+), 37 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3517c95251..fba13d4a43 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -44703,25 +44703,162 @@ Sound Home Services

 @node Mail Home Services
 @subsection Mail Home Services
-
+
 The @code{(gnu home services mail)} module provides services that help
 you set up the tools to work with emails in your home environment.
-
+
+@cindex goimapnotify
+@uref{https://gitlab.com/shackra/goimapnotify, goimapnotify} watches your
+mailbox(es) and executes a script on (new / deleted / updated) messages.
+
+Using @code{home-goimapnotify-configuration}, you can generate a config file
+for each account you want to watch (file name relative to @code{$HOME}), e.g.:
+
+@lisp
+(simple-service 'mail-imapnotify-config-examples
+                home-goimapnotify-service-type
+                (home-goimapnotify-configuration
+                  (accounts (list
+                              `(".config/goimapnotify/private-account.conf"
+                                ,(goimapnotify-account
+                                    (host "imap.example.org")
+                                    (port 993)
+                                    (tls #t)
+                                    (username "example")
+                                    (password-cmd "pass my-private-email-account")
+                                    (on-new-mail
+                                      (file-append mbsync "/bin/mbsync private-account"))
+                                    (on-new-mail-post
+                                      (file-append mu "/bin/mu index"))
+                                    (boxes '("INBOX"))))
+                              `(".config/goimapnotify/work-account.conf"
+                                ,(goimapnotify-account
+                                    (host "imap.work.example.org")
+                                    (port 993)
+                                    (tls #t)
+                                    (username "example")
+                                    (password "12345")
+                                    (on-new-mail
+                                      (file-append mbsync "/bin/mbsync work-account"))
+                                    (on-new-mail-post
+                                      "notify-send 'New mail'")
+                                    (boxes '("INBOX"
+                                            "On Call")))))))))
+@end lisp
+
+Note: to utilize the config files, you need to start a separate goimapnotify
+process for each one.  Continuing the example above:
+@code{goimapnotify -conf "$HOME/.config/goimapnotify/private-account.conf"} and
+@code{goimapnotify -conf "$HOME/.config/goimapnotify/work-account.conf"}.
+
+@c %start of fragment
+@deftp {Data Type} home-goimapnotify-configuration
+Available @code{home-goimapnotify-configuration} fields are:
+
+@table @asis
+@item @code{accounts} (default: @code{()}) (type: list-of-goimapnotify-accounts)
+List of accounts that goimapnotify should watch.  For each account, a
+separate configuration file will be generated.
+@end table
+
+@end deftp
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} goimapnotify-account
+Available @code{goimapnotify-account} fields are:
+
+@table @asis
+@item @code{host} (type: maybe-string)
+Address of the IMAP server to connect to.
+
+@item @code{host-cmd} (type: maybe-string-or-file-like)
+An executable or script that retrieves your host from somewhere, we
+cannot pass arguments to this command from Stdin.
+
+@item @code{port} (type: maybe-integer)
+Port of the IMAP server to connect to.
+
+@item @code{tls} (type: maybe-boolean)
+
+Use TLS?
+
+@item @code{tls-options} (type: maybe-goimapnotify-tls-options)
+Option(s) for the TLS connection.  Currently, only one option is
+supported.
+
+@item @code{username} (type: maybe-string)
+Username for authentication.
+
+@item @code{username-cmd} (type: maybe-string-or-file-like)
+An executable or script that retrieves your username from
+somewhere, we cannot pass arguments to this command from Stdin.
+
+@item @code{password} (type: maybe-string)
+Password for authentication.
+
+@item @code{password-cmd} (type:
+ maybe-string-or-file-like)
+An executable or script that retrieves your password from somewhere, we
+cannot pass arguments to this command from Stdin.
+
+@item @code{xoauth2}
+(type: maybe-boolean)
+You can also use xoauth2 instead of password based authentication by
+setting the xoauth2 option to true and the output of a tool which can
+provide xoauth2 encoded tokens in passwordCmd.  Examples:
+@uref{https://github.com/google/oauth2l,Google oauth2l} or
+@uref{https://github.com/harishkrupo/oauth2ms,xoauth2 fetcher for O36
+5}.
+
+@item @code{on-new-mail} (type: maybe-string-or-file-like)
+An executable or script to run when new mail has arrived.
+
+@item @code{on-new-mail-post} (type: maybe-string-or-file-like)
+An executable or script to run after onNewMail has ran.
+
+@item @code{wait} (type: maybe-integer)
+The delay in seconds before the mail syncing is triggered.
+
+@item @code{boxes} (type: maybe-list-of-strings)
+Mailboxes to watch.
+
+@end table
+
+@end deftp
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} goimapnotify-tls-options
+Available @code{goimapnotify-tls-options} fields are:
+
+@table @asis
+@item @code{reject-unauthorized} (type: maybe-boolean)
+Skip verifying CA server identify?
+
+@end table
+
+@end deftp
+@c %end of fragment
+
 @cindex msmtp
 @uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail
 Transfer Protocol} client.  It sends mail to a predefined SMTP server
 that takes care of proper delivery.
-
+
 The service reference is given below.
-
+
 @defvar home-msmtp-service-type
 This is the service type for @command{msmtp}.  Its value must be a
 @code{home-msmtp-configuration}, as shown below.  It provides the
 @file{~/.config/msmtp/config} file.
-
+
 As an example, here is how you would configure @code{msmtp} for a single
 account:
-
+
 @lisp
 (service home-msmtp-service-type
          (home-msmtp-configuration
@@ -44739,101 +44876,101 @@ Mail Home Services
 @end defvar

 @c %start of fragment
-
+
 @deftp {Data Type} home-msmtp-configuration
 Available @code{home-msmtp-configuration} fields are:
-
+
 @table @asis
 @item @code{defaults} (type: msmtp-configuration)
 The configuration that will be set as default for all accounts.
-
+
 @item @code{accounts} (default: @code{'()}) (type: list-of-msmtp-accounts)
 A list of @code{msmtp-account} records which contain information about
 all your accounts.
-
+
 @item @code{default-account} (type: maybe-string)
 Set the default account.
-
+
 @item @code{extra-content} (default: @code{""}) (type: string)
 Extra content appended as-is to the configuration file.  Run
 @command{man msmtp} for more information about the configuration file
 format.
-
+
 @end table
-
+
 @end deftp
-
+
 @c %end of fragment
-
+
 @c %start of fragment
-
+
 @deftp {Data Type} msmtp-account
 Available @code{msmtp-account} fields are:
-
+
 @table @asis
 @item @code{name} (type: string)
 The unique name of the account.
-
+
 @item @code{configuration} (type: msmtp-configuration)
 The configuration for this given account.
-
+
 @end table
-
+
 @end deftp
-
+
 @c %end of fragment

 @c %start of fragment
-
+
 @deftp {Data Type} msmtp-configuration
 Available @code{msmtp-configuration} fields are:
-
+
 @table @asis
 @item @code{auth?} (type: maybe-boolean)
 Enable or disable authentication.
-
+
 @item @code{tls?} (type: maybe-boolean)
 Enable or disable TLS (also known as SSL) for secured connections.
-
+
 @item @code{tls-starttls?} (type: maybe-boolean)
 Choose the TLS variant: start TLS from within the session (‘on’,
 default), or tunnel the session through TLS (‘off’).
-
+
 @item @code{tls-trust-file} (type: maybe-string)
 Activate server certificate verification using a list of trusted
 Certification Authorities (CAs).
-
+
 @item @code{log-file} (type: maybe-string)
 Enable logging to the specified file.  An empty argument disables
 logging.  The file name ‘-’ directs the log information to standard
 output.
-
+
 @item @code{host} (type: maybe-string)
 The SMTP server to send the mail to.
-
+
 @item @code{port} (type: maybe-integer)
 The port that the SMTP server listens on.  The default is 25 ("smtp"),
 unless TLS without STARTTLS is used, in which case it is 465 ("smtps").
-
+
 @item @code{user} (type: maybe-string)
 Set the user name for authentication.
-
+
 @item @code{from} (type: maybe-string)
 Set the envelope-from address.
-
+
 @item @code{password-eval} (type: maybe-string)
 Set the password for authentication to the output (stdout) of the
 command cmd.
-
+
 @item @code{extra-content} (default: @code{""}) (type: string)
 Extra content appended as-is to the configuration block.  Run
 @command{man msmtp} for more information about the configuration file
 format.
-
+
 @end table
-
+
 @end deftp
-
+
 @c %end of fragment

 @node Messaging Home Services
diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm
index 5445c82c67..923867ca66 100644
--- a/gnu/home/services/mail.scm
+++ b/gnu/home/services/mail.scm
@@ -18,15 +18,44 @@

 (define-module (gnu home services mail)
   #:use-module (guix gexp)
+  #:use-module (guix records)
   #:use-module (gnu services)
   #:use-module (gnu services configuration)
   #:use-module (gnu home services)
   #:use-module (gnu home services shepherd)
+  #:use-module (gnu home services utils)
   #:use-module (gnu packages mail)
+  #:use-module (gnu packages guile)
+  #:use-module (ice-9 match)
   #:use-module (ice-9 string-fun)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (home-msmtp-configuration
+  #:export (home-goimapnotify-configuration
+            home-goimapnotify-configuration-fields
+            home-goimapnotify-configuration?
+            home-goimapnotify-configuration-accounts
+            home-goimapnotify-service-type
+            goimapnotify-account
+            goimapnotify-account-fields
+            goimapnotify-account-host
+            goimapnotify-account-host-cmd
+            goimapnotify-account-port
+            goimapnotify-account-tls
+            goimapnotify-account-tls-options
+            goimapnotify-account-username
+            goimapnotify-account-username-cmd
+            goimapnotify-account-password
+            goimapnotify-account-password-cmd
+            goimapnotify-account-xoauth2
+            goimapnotify-account-on-new-mail
+            goimapnotify-account-on-new-mail-post
+            goimapnotify-account-wait
+            goimapnotify-account-boxes
+            goimapnotify-tls-options
+            goimapnotify-tls-options-fields
+            goimapnotify-tls-options-reject-unauthorized
+
+            home-msmtp-configuration
             home-msmtp-configuration?
             home-msmtp-configuration-defaults
             home-msmtp-configuration-accounts
@@ -220,3 +249,206 @@ (define home-msmtp-service-type
                 (description "Configure msmtp, a simple
 @acronym{SMTP, Simple Mail Transfer Protocol} client that can relay email
 to SMTP servers.")))
+
+; Configuration for goimapnotify from (gnu packages mail)
+
+(define-maybe string)
+(define-maybe integer)
+(define-maybe boolean)
+(define-maybe list-of-strings)
+(define-maybe string-or-file-like)
+
+(define (string-or-file-like? value)
+  (or (string? value)
+      (file-like? value)))
+
+(define (goimapnotify-format-field field-name)
+  (object->camel-case-string field-name))
+
+(define (goimapnotify-serialize-field field-name value)
+  "This is converted to JSON later, so we don't return a string here"
+  #~(#$(goimapnotify-format-field field-name) . #$value))
+
+(define (goimapnotify-serialize-string-or-file-like field-name value)
+  (goimapnotify-serialize-string field-name value))
+
+(define (goimapnotify-maybe-serialize field-name value serialization-function)
+  (if (maybe-value-set? value)
+    (serialization-function field-name value)
+    ""))
+
+(define (goimapnotify-serialize-maybe-string-or-file-like field-name value)
+ (goimapnotify-maybe-serialize field-name value
+                               goimapnotify-serialize-string-or-file-like))
+
+(define goimapnotify-serialize-string goimapnotify-serialize-field)
+(define (goimapnotify-serialize-maybe-string field-name value)
+ (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-string))
+
+(define (goimapnotify-serialize-maybe-integer field-name value)
+ (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-integer))
+(define goimapnotify-serialize-integer goimapnotify-serialize-field)
+
+(define (goimapnotify-serialize-maybe-boolean field-name value)
+  (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-boolean))
+(define goimapnotify-serialize-boolean goimapnotify-serialize-field)
+
+(define (goimapnotify-serialize-maybe-list-of-strings field-name value)
+  (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-list-of-strings))
+(define (goimapnotify-serialize-list-of-strings field-name value)
+  (goimapnotify-serialize-field field-name (list->array 1 value)))
+
+(define (goimapnotify-serialize-maybe-goimapnotify-tls-options field-name config)
+  (goimapnotify-maybe-serialize field-name config
+                                goimapnotify-serialize-goimapnotify-tls-options))
+
+(define (goimapnotify-serialize-goimapnotify-tls-options field-name config)
+  (goimapnotify-serialize-field
+    field-name
+    (prepare-configuration-for-json config goimapnotify-tls-options-fields)))
+
+(define (prepare-configuration-for-json config fields)
+  "Convert the configuration to the format expected by guile-json.
+  Unset maybe-values do not appear in the configuration file."
+  (filter
+    (lambda (val)
+      (not (unspecified? val)))
+    (map
+      (lambda (field)
+        (let ((value ((configuration-field-getter field) config)))
+          (if (maybe-value-set? value)
+            ((configuration-field-serializer field)
+             (configuration-field-name field)
+             value)
+            *unspecified*)))
+      fields)))
+
+(define-configuration goimapnotify-tls-options
+                      (reject-unauthorized
+                        (maybe-boolean)
+                        "Skip verifying CA server identify?")
+                      (prefix goimapnotify-))
+
+(define-maybe goimapnotify-tls-options)
+
+; See https://gitlab.com/shackra/goimapnotify/-/blob/master/config.go?ref_type=heads#L46-62
+(define-configuration goimapnotify-account
+                      (host
+                        (maybe-string)
+                        "Address of the IMAP server to connect to.")
+                      (host-cmd
+                        (maybe-string-or-file-like)
+                        "An executable or script that retrieves your host from somewhere,
+                        we cannot pass arguments to this command from Stdin.")
+                      (port
+                        (maybe-integer)
+                        "Port of the IMAP server to connect to.")
+                      (tls
+                        (maybe-boolean)
+                        "Use TLS?")
+                      (tls-options
+                        (maybe-goimapnotify-tls-options)
+                        "Option(s) for the TLS connection. Currently, only one option is
+                        supported.")
+                      (username
+                        (maybe-string)
+                        "Username for authentication.")
+                      (username-cmd
+                        (maybe-string-or-file-like)
+                        "An executable or script that retrieves your username from
+                        somewhere, we cannot pass arguments to this command from Stdin.")
+                      (password
+                        (maybe-string)
+                        "Password for authentication.")
+                      (password-cmd
+                        (maybe-string-or-file-like)
+                        "An executable or script that retrieves your password from
+                        somewhere, we cannot pass arguments to this command from Stdin.")
+                      (xoauth2
+                        (maybe-boolean)
+                        "You can also use xoauth2 instead of password based authentication
+                        by setting the xoauth2 option to true and the output of a tool
+                        which can provide xoauth2 encoded tokens in passwordCmd.
+                        Examples: @url{https://github.com/google/oauth2l, Google oauth2l}
+                        or
+                        @url{https://github.com/harishkrupo/oauth2ms, xoauth2 fetcher for O365}.")
+                      (on-new-mail
+                        (maybe-string-or-file-like)
+                        "An executable or script to run when new mail has arrived.")
+                      (on-new-mail-post
+                        (maybe-string-or-file-like)
+                        "An executable or script to run after onNewMail has ran.")
+                      (wait
+                        (maybe-integer)
+                        "The delay in seconds before the mail syncing is triggered.")
+                      (boxes
+                        (maybe-list-of-strings)
+                        "Mailboxes to watch.")
+                      (prefix goimapnotify-))
+
+(define (list-of-goimapnotify-accounts? lst)
+  "List is in the form of '((file-name file-like))"
+  (every (lambda (element)
+           (match element
+                  ((string ($ <goimapnotify-account>))
+                   #t)
+                  (_ #f)))
+         lst))
+
+(define-configuration/no-serialization home-goimapnotify-configuration
+                                       (accounts
+                                         (list-of-goimapnotify-accounts '())
+                                         "List of accounts that goimapnotify should watch.
+                                         For each account, a separate configuration file
+                                         will be generated."))
+
+(define (home-goimapnotify-extension old-config extensions)
+  (match-record old-config <home-goimapnotify-configuration>
+                (accounts)
+                (home-goimapnotify-configuration
+                  (inherit old-config)
+                  (accounts (append accounts
+                                    (append-map
+                                      home-goimapnotify-configuration-accounts
+                                      extensions))))))
+
+(define (goimapnotify-files config)
+  (define* (account->json account-config-and-path)
+    (match
+      account-config-and-path
+      ((path account-config)
+       (let ((prepared-config
+               (prepare-configuration-for-json
+                 account-config
+                 goimapnotify-account-fields)))
+         `((,path
+            ,(computed-file
+               (string-append
+                 "mail-imapnotify-config-"
+                 (goimapnotify-account-host account-config))
+               (with-extensions (list guile-json-4)
+                   #~(begin
+                       (use-modules (json builder))
+
+                       (with-output-to-file #$output
+                         (lambda ()
+                           (scm->json '(#$@prepared-config)
+                                      #:pretty #t))))))))))))
+
+  (match-record config <home-goimapnotify-configuration>
+                (accounts)
+                (append-map
+                  (cut account->json <>)
+                  accounts)))
+
+(define home-goimapnotify-service-type
+  (service-type (name 'home-goimapnotify-service)
+                (extensions
+                  (list (service-extension
+                          home-files-service-type
+                          goimapnotify-files)))
+                (compose identity)
+                (extend home-goimapnotify-extension)
+                (default-value (home-goimapnotify-configuration))
+                (description "Configure goimapnotify to execute scripts on IMAP
+                             mailbox changes.")))

base-commit: d2923babf3ac44cb6faa88317f77c98f3016820d
--
2.41.0




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Nils Landt <nils@HIDDEN>
Subject: bug#66557: Acknowledgement ([PATCH] home: services: Add
 goimapnotify service.)
Message-ID: <handler.66557.B.169737855718116.ack <at> debbugs.gnu.org>
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
X-Gnu-PR-Message: ack 66557
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 66557 <at> debbugs.gnu.org
Date: Sun, 15 Oct 2023 14:03:01 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

As you requested using X-Debbugs-CC, your message was also forwarded to
  ( <paren@HIDDEN>, Andrew Tropin <andrew@HIDDEN>, Ludovic Court=C3=
=A8s <ludo@HIDDEN>
(after having been given a bug report number, if it did not have one).

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 66557 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
66557: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66557
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Resent-From: Ricardo Wurmus <rekado@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 02 Nov 2023 10:00:02 +0000
Resent-Message-ID: <handler.66557.B66557.16989191902316 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66557 <at> debbugs.gnu.org
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.16989191902316
          (code B ref 66557); Thu, 02 Nov 2023 10:00:02 +0000
Received: (at 66557) by debbugs.gnu.org; 2 Nov 2023 09:59:50 +0000
Received: from localhost ([127.0.0.1]:53958 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qyUUQ-0000bI-7p
	for submit <at> debbugs.gnu.org; Thu, 02 Nov 2023 05:59:50 -0400
Received: from sender3-of-o57.zoho.com ([136.143.184.57]:21756)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rekado@HIDDEN>) id 1qyUUM-0000b6-Bm
 for 66557 <at> debbugs.gnu.org; Thu, 02 Nov 2023 05:59:49 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1698919148; cv=none; 
 d=zohomail.com; s=zohoarc; 
 b=LztJ6BJW7uhw1ara1Zj+KV8dEH+Du0WtQ3zMvoGnHEAeQpYThLADFgn3IY0sehOt/K7hbM7Mx9HL4VWQp6KNI3ShWw2SCcQfSZvBNyCzWzrqA/hBPx7LgIpBdtojWKbWwNfC8qHUh9qUtCy8e3YC/6A4DMsiHvYpDT6p9hsKf18=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc; t=1698919148;
 h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc;
 bh=am884MdGVInPKPe/eCrgs2XyfQmOe2c1fOvbiNuR+ac=; 
 b=BaGe3pRoNfHwno99Iu1doU5QK7+5Iq90RvERS/7uZr3pT1RWjNwtiZDb5BypQsoVSSuG2ExFeZtdEX+QEh1Kfy1TIjC0JZGdIkJLPCVgbTTD9t4TorrdreSpfXobXefjhQJgO1+QWFR/loI80hsckA56m+WLTukNRw0G/7MSA8s=
ARC-Authentication-Results: i=1; mx.zohomail.com;
 dkim=pass  header.i=elephly.net;
 spf=pass  smtp.mailfrom=rekado@HIDDEN;
 dmarc=pass header.from=<rekado@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1698919148; 
 s=zoho; d=elephly.net; i=rekado@HIDDEN;
 h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc;
 bh=am884MdGVInPKPe/eCrgs2XyfQmOe2c1fOvbiNuR+ac=;
 b=Llo0p1yTBjBI5kS503LT+G9ocoYk/zxzPWIXn4aIrK86LfdFRXzZgUMfmxXYulfP
 1sN+HTDxaaecGPQDwwWvoYGMak+nhKxrUPOtdwis9F6pB0orYhAPtjPJMmcQvoHWm4o
 EiLAAHOpG8W0P/h8HBcw8ccH891wXGXzesMqWVHc=
Received: from localhost (215-110-142-46.pool.kielnet.net [46.142.110.215]) by
 mx.zohomail.com with SMTPS id 1698919145488104.9143966336178;
 Thu, 2 Nov 2023 02:59:05 -0700 (PDT)
User-agent: mu4e 1.10.7; emacs 29.1
From: Ricardo Wurmus <rekado@HIDDEN>
Date: Thu, 02 Nov 2023 09:55:15 +0100
Message-ID: <87h6m4tr15.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-ZohoMailClient: External
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Nils,

thank you for this service!  I had been looking for a goimapnotify
service just a few days ago, so this will definitely come in handy.

I don=E2=80=99t have the time for a comprehensive review, but I=E2=80=99ll =
comment on a
few things that stuck out to me.

> +                                    (password-cmd "pass my-private-email=
-account")
> +                                    (on-new-mail
> +                                      (file-append mbsync "/bin/mbsync p=
rivate-account"))

It seems wrong to me to compose a command as a single string.  Usually
we separate the executable from the arguments.  People who want to run
the command in a shell can still do that by using =E2=80=9C/bin/sh=E2=80=9D=
 =E2=80=9C-c=E2=80=9D
=E2=80=9Ccommand string=E2=80=9D.

So I think it would be better to let these fields accept command lists.
FILE-APPEND should only join the package value with the file name of the
executable, but not include any arguments.

I suppose these values end up in the generated configuration file as
plain strings anyway, so perhaps it doesn=E2=80=99t matter much.  In that c=
ase
please also use FILE-APPEND to embed a reference to PASS.

> +(define (goimapnotify-serialize-field field-name value)
> +  "This is converted to JSON later, so we don't return a string here"
> +  #~(#$(goimapnotify-format-field field-name) . #$value))

Could this be (cons (goimapnotify-format-field field-name) value)
instead?  I don=E2=80=99t think we need this wrapping and unwrapping with G=
-exp
syntax.

> +(define (prepare-configuration-for-json config fields)
> +  "Convert the configuration to the format expected by guile-json.
> +  Unset maybe-values do not appear in the configuration file."
> +  (filter
> +    (lambda (val)
> +      (not (unspecified? val)))
> +    (map
> +      (lambda (field)
> +        (let ((value ((configuration-field-getter field) config)))
> +          (if (maybe-value-set? value)
> +            ((configuration-field-serializer field)
> +             (configuration-field-name field)
> +             value)
> +            *unspecified*)))
> +      fields)))

This looks a little too convoluted to me.  It=E2=80=99s the IF with the
*UNSPECIFIED* as the second branch (followed by the filter) that doesn=E2=
=80=99t
strike me as nice.  Perhaps you simplify this with a fold?

In any case, the filter predicate could be (negate unspecified?) instead
of the lambda expression.

> ; See https://gitlab.com/shackra/goimapnotify/-/blob/master/config.go?ref=
_type=3Dheads#L46-62

Please don=E2=80=99t use =E2=80=9Cmaster=E2=80=9D here, because it=E2=80=99=
s a moving target, so the
line anchors will become out of date.  Please use an arbitrary recent
commit instead.  Since this is a line comment please use =E2=80=9C;;=E2=80=
=9D instead of
=E2=80=9C;=E2=80=9D (which is used for comments in the margin).

> +(define (list-of-goimapnotify-accounts? lst)
> +  "List is in the form of '((file-name file-like))"
> +  (every (lambda (element)
> +           (match element
> +                  ((string ($ <goimapnotify-account>))
> +                   #t)
> +                  (_ #f)))
> +         lst))

The indentation for the MATCH clauses is too deep.  There are other
instances of oddly deep indentation, such as the body of
=E2=80=9C(define-configuration/no-serialization home-goimapnotify-configura=
tion
=E2=80=A6)=E2=80=9D.  Are you using Emacs?

Since you=E2=80=99re throwing away the first element you can reduce this to:

  (every (compose goimapnotify-account? second) lst)

I haven=E2=80=99t looked at the documentation much, but the capitalization =
of
=E2=80=9CStdin=E2=80=9D and the spurious changes to seemingly empty lines i=
n existing
documentation stood out to me.  It would be better to undo the changes
to unrelated documentation in the same file.

--=20
Ricardo




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
Resent-From: Bruno Victal <mirai@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Mon, 20 Nov 2023 17:17:01 +0000
Resent-Message-ID: <handler.66557.B66557.1700500599364 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.1700500599364
          (code B ref 66557); Mon, 20 Nov 2023 17:17:01 +0000
Received: (at 66557) by debbugs.gnu.org; 20 Nov 2023 17:16:39 +0000
Received: from localhost ([127.0.0.1]:54360 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r57t0-00005m-1Q
	for submit <at> debbugs.gnu.org; Mon, 20 Nov 2023 12:16:38 -0500
Received: from smtpm3.myservices.hosting ([185.26.105.234]:59420)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1r57sx-00005Q-EX
 for 66557 <at> debbugs.gnu.org; Mon, 20 Nov 2023 12:16:36 -0500
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm3.myservices.hosting (Postfix) with ESMTP id CB79C20FA7;
 Mon, 20 Nov 2023 18:16:30 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 443CF80092;
 Mon, 20 Nov 2023 18:16:27 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id C8dHNtBGiehZ; Mon, 20 Nov 2023 18:16:26 +0100 (CET)
Received: from [192.168.1.116] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 5BF6780079;
 Mon, 20 Nov 2023 18:16:26 +0100 (CET)
Message-ID: <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
Date: Mon, 20 Nov 2023 17:16:25 +0000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: Bruno Victal <mirai@HIDDEN>
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Content-Language: en-US
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------ktqh07dFjGbp4K27zTEBzkDk"
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------ktqh07dFjGbp4K27zTEBzkDk
Content-Type: multipart/mixed; boundary="------------1nSCjVH3KzEBNhKYYg95Fy7I";
 protected-headers="v1"
From: Bruno Victal <mirai@HIDDEN>
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Message-ID: <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
Subject: Re: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>

--------------1nSCjVH3KzEBNhKYYg95Fy7I
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Nils,

On 2023-10-15 15:01, Nils Landt wrote:
> This patch adds a home service for generating goimapnotify JSON
> configuration files.

[=E2=80=A6]

> +@lisp
> +(simple-service 'mail-imapnotify-config-examples
> +                home-goimapnotify-service-type
> +                (home-goimapnotify-configuration
> +                  (accounts (list
> +                              `(".config/goimapnotify/private-account.=
conf"
> +                                ,(goimapnotify-account
> +                                    (host "imap.example.org")
> +                                    (port 993)
> +                                    (tls #t)
> +                                    (username "example")
> +                                    (password-cmd "pass my-private-ema=
il-account")
> +                                    (on-new-mail
> +                                      (file-append mbsync "/bin/mbsync=
 private-account"))
> +                                    (on-new-mail-post
> +                                      (file-append mu "/bin/mu index")=
)
> +                                    (boxes '("INBOX"))))
> +                              `(".config/goimapnotify/work-account.con=
f"
> +                                ,(goimapnotify-account
> +                                    (host "imap.work.example.org")
> +                                    (port 993)
> +                                    (tls #t)
> +                                    (username "example")
> +                                    (password "12345")
> +                                    (on-new-mail
> +                                      (file-append mbsync "/bin/mbsync=
 work-account"))
> +                                    (on-new-mail-post
> +                                      "notify-send 'New mail'")
> +                                    (boxes '("INBOX"
> +                                            "On Call")))))))))
> +@end lisp
> +
> +Note: to utilize the config files, you need to start a separate goimap=
notify
> +process for each one.  Continuing the example above:
> +@code{goimapnotify -conf "$HOME/.config/goimapnotify/private-account.c=
onf"} and
> +@code{goimapnotify -conf "$HOME/.config/goimapnotify/work-account.conf=
"}.

Not a goimapnotify user but this looks like a daemon application.
I don't like this design much, I think goimapnotify should be launched an=
d managed
using shepherd instead of simply exposing these files to the user.

> +@item @code{tls} (type: maybe-boolean)
> +
> +Use TLS?

Boolean fields are generally suffixed with '?'. (e.g. tls?)

> +@item @code{tls-options} (type: maybe-goimapnotify-tls-options)
> +Option(s) for the TLS connection.  Currently, only one option is
> +supported.
> +
> +@item @code{username} (type: maybe-string)
> +Username for authentication.
> +
> +@item @code{username-cmd} (type: maybe-string-or-file-like)
> +An executable or script that retrieves your username from
> +somewhere, we cannot pass arguments to this command from Stdin.

I'd prefer to write it as =E2=80=9Cstdin=E2=80=9D (lowercase) or expand i=
t to =E2=80=9Cstandard input=E2=80=9D.

> +@item @code{xoauth2}
> +(type: maybe-boolean)
> +You can also use xoauth2 instead of password based authentication by
> +setting the xoauth2 option to true and the output of a tool which can
> +provide xoauth2 encoded tokens in passwordCmd.  Examples:
> +@uref{https://github.com/google/oauth2l,Google oauth2l} or
> +@uref{https://github.com/harishkrupo/oauth2ms,xoauth2 fetcher for O36
> +5}.

Same remark as 'tls' option.

> +@item @code{on-new-mail} (type: maybe-string-or-file-like)
> +An executable or script to run when new mail has arrived.
> +
> +@item @code{on-new-mail-post} (type: maybe-string-or-file-like)
> +An executable or script to run after onNewMail has ran.

=E2=80=9CAn executable or script to run after @code{on-new-mail} has ran.=
=E2=80=9D

> +@table @asis
> +@item @code{reject-unauthorized} (type: maybe-boolean)
> +Skip verifying CA server identify?

Same remark as 'tls' option.

>  @cindex msmtp
>  @uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail
>  Transfer Protocol} client.  It sends mail to a predefined SMTP server
>  that takes care of proper delivery.
> -
> +
>  The service reference is given below.
> -
> +
>  @defvar home-msmtp-service-type
>  This is the service type for @command{msmtp}.  Its value must be a
>  @code{home-msmtp-configuration}, as shown below.  It provides the
>  @file{~/.config/msmtp/config} file.
> -
> +
>  As an example, here is how you would configure @code{msmtp} for a sing=
le
>  account:
> -
> +
>  @lisp
>  (service home-msmtp-service-type
>           (home-msmtp-configuration
> @@ -44739,101 +44876,101 @@ Mail Home Services
>  @end defvar
>=20
>  @c %start of fragment
> -
> +
>  @deftp {Data Type} home-msmtp-configuration
>  Available @code{home-msmtp-configuration} fields are:
> -
> +
>  @table @asis
>  @item @code{defaults} (type: msmtp-configuration)
>  The configuration that will be set as default for all accounts.
> -
> +
>  @item @code{accounts} (default: @code{'()}) (type: list-of-msmtp-accou=
nts)
>  A list of @code{msmtp-account} records which contain information about=

>  all your accounts.
> -
> +
>  @item @code{default-account} (type: maybe-string)
>  Set the default account.
> -
> +
>  @item @code{extra-content} (default: @code{""}) (type: string)
>  Extra content appended as-is to the configuration file.  Run
>  @command{man msmtp} for more information about the configuration file
>  format.
> -
> +
>  @end table
> -
> +
>  @end deftp
> -
> +
>  @c %end of fragment
> -
> +
>  @c %start of fragment
> -
> +
>  @deftp {Data Type} msmtp-account
>  Available @code{msmtp-account} fields are:
> -
> +
>  @table @asis
>  @item @code{name} (type: string)
>  The unique name of the account.
> -
> +
>  @item @code{configuration} (type: msmtp-configuration)
>  The configuration for this given account.
> -
> +
>  @end table
> -
> +
>  @end deftp
> -
> +
>  @c %end of fragment
>=20
>  @c %start of fragment
> -
> +
>  @deftp {Data Type} msmtp-configuration
>  Available @code{msmtp-configuration} fields are:
> -
> +
>  @table @asis
>  @item @code{auth?} (type: maybe-boolean)
>  Enable or disable authentication.
> -
> +
>  @item @code{tls?} (type: maybe-boolean)
>  Enable or disable TLS (also known as SSL) for secured connections.
> -
> +
>  @item @code{tls-starttls?} (type: maybe-boolean)
>  Choose the TLS variant: start TLS from within the session (=E2=80=98on=
=E2=80=99,
>  default), or tunnel the session through TLS (=E2=80=98off=E2=80=99).
> -
> +
>  @item @code{tls-trust-file} (type: maybe-string)
>  Activate server certificate verification using a list of trusted
>  Certification Authorities (CAs).
> -
> +
>  @item @code{log-file} (type: maybe-string)
>  Enable logging to the specified file.  An empty argument disables
>  logging.  The file name =E2=80=98-=E2=80=99 directs the log informatio=
n to standard
>  output.
> -
> +
>  @item @code{host} (type: maybe-string)
>  The SMTP server to send the mail to.
> -
> +
>  @item @code{port} (type: maybe-integer)
>  The port that the SMTP server listens on.  The default is 25 ("smtp"),=

>  unless TLS without STARTTLS is used, in which case it is 465 ("smtps")=
=2E
> -
> +
>  @item @code{user} (type: maybe-string)
>  Set the user name for authentication.
> -
> +
>  @item @code{from} (type: maybe-string)
>  Set the envelope-from address.
> -
> +
>  @item @code{password-eval} (type: maybe-string)
>  Set the password for authentication to the output (stdout) of the
>  command cmd.
> -
> +
>  @item @code{extra-content} (default: @code{""}) (type: string)
>  Extra content appended as-is to the configuration block.  Run
>  @command{man msmtp} for more information about the configuration file
>  format.
> -
> +
>  @end table
> -
> +
>  @end deftp
> -
> +
>  @c %end of fragment

These are unrelated changes, can you drop these hunks?

> +(define (goimapnotify-maybe-serialize field-name value serialization-f=
unction)
> +  (if (maybe-value-set? value)
> +    (serialization-function field-name value)
> +    ""))
> +
> +(define (goimapnotify-serialize-maybe-string-or-file-like field-name v=
alue)
> + (goimapnotify-maybe-serialize field-name value
> +                               goimapnotify-serialize-string-or-file-l=
ike))
> +
> +(define goimapnotify-serialize-string goimapnotify-serialize-field)
> +(define (goimapnotify-serialize-maybe-string field-name value)
> + (goimapnotify-maybe-serialize field-name value goimapnotify-serialize=
-string))
> +
> +(define (goimapnotify-serialize-maybe-integer field-name value)
> + (goimapnotify-maybe-serialize field-name value goimapnotify-serialize=
-integer))
> +(define goimapnotify-serialize-integer goimapnotify-serialize-field)
> +
> +(define (goimapnotify-serialize-maybe-boolean field-name value)
> +  (goimapnotify-maybe-serialize field-name value goimapnotify-serializ=
e-boolean))
> +(define goimapnotify-serialize-boolean goimapnotify-serialize-field)
> +
> +(define (goimapnotify-serialize-maybe-list-of-strings field-name value=
)
> +  (goimapnotify-maybe-serialize field-name value goimapnotify-serializ=
e-list-of-strings))
> +(define (goimapnotify-serialize-list-of-strings field-name value)
> +  (goimapnotify-serialize-field field-name (list->array 1 value)))
> +
> +(define (goimapnotify-serialize-maybe-goimapnotify-tls-options field-n=
ame config)
> +  (goimapnotify-maybe-serialize field-name config
> +                                goimapnotify-serialize-goimapnotify-tl=
s-options))

This isn't needed, fields whose maybe-values are unset don't call the
serializing procedures.

> +(define (goimapnotify-serialize-goimapnotify-tls-options field-name co=
nfig)
> +  (goimapnotify-serialize-field
> +    field-name
> +    (prepare-configuration-for-json config goimapnotify-tls-options-fi=
elds)))
> +
> +(define (prepare-configuration-for-json config fields)
> +  "Convert the configuration to the format expected by guile-json.
> +  Unset maybe-values do not appear in the configuration file."
> +  (filter
> +    (lambda (val)
> +      (not (unspecified? val)))
> +    (map
> +      (lambda (field)
> +        (let ((value ((configuration-field-getter field) config)))
> +          (if (maybe-value-set? value)
> +            ((configuration-field-serializer field)
> +             (configuration-field-name field)
> +             value)
> +            *unspecified*)))
> +      fields)))

You can use 'serialize-configuration' instead which accounts for the unse=
t maybe-values.

> +
> +(define-configuration goimapnotify-tls-options
> +                      (reject-unauthorized
> +                        (maybe-boolean)
> +                        "Skip verifying CA server identify?")
> +                      (prefix goimapnotify-))
> +
> +(define-maybe goimapnotify-tls-options)
> +
> +; See https://gitlab.com/shackra/goimapnotify/-/blob/master/config.go?=
ref_type=3Dheads#L46-62
> +(define-configuration goimapnotify-account
> +                      (host
> +                        (maybe-string)
> +                        "Address of the IMAP server to connect to.")
> +                      (host-cmd
> +                        (maybe-string-or-file-like)
> +                        "An executable or script that retrieves your h=
ost from somewhere,
> +                        we cannot pass arguments to this command from =
Stdin.")
> +                      (port
> +                        (maybe-integer)
> +                        "Port of the IMAP server to connect to.")
> +                      (tls
> +                        (maybe-boolean)
> +                        "Use TLS?")
> +                      (tls-options
> +                        (maybe-goimapnotify-tls-options)
> +                        "Option(s) for the TLS connection. Currently, =
only one option is
> +                        supported.")
> +                      (username
> +                        (maybe-string)
> +                        "Username for authentication.")
> +                      (username-cmd
> +                        (maybe-string-or-file-like)
> +                        "An executable or script that retrieves your u=
sername from
> +                        somewhere, we cannot pass arguments to this co=
mmand from Stdin.")
> +                      (password
> +                        (maybe-string)
> +                        "Password for authentication.")
> +                      (password-cmd
> +                        (maybe-string-or-file-like)
> +                        "An executable or script that retrieves your p=
assword from
> +                        somewhere, we cannot pass arguments to this co=
mmand from Stdin.")
> +                      (xoauth2
> +                        (maybe-boolean)
> +                        "You can also use xoauth2 instead of password =
based authentication
> +                        by setting the xoauth2 option to true and the =
output of a tool
> +                        which can provide xoauth2 encoded tokens in pa=
sswordCmd.
> +                        Examples: @url{https://github.com/google/oauth=
2l, Google oauth2l}
> +                        or
> +                        @url{https://github.com/harishkrupo/oauth2ms, =
xoauth2 fetcher for O365}.")
> +                      (on-new-mail
> +                        (maybe-string-or-file-like)
> +                        "An executable or script to run when new mail =
has arrived.")
> +                      (on-new-mail-post
> +                        (maybe-string-or-file-like)
> +                        "An executable or script to run after onNewMai=
l has ran.")
> +                      (wait
> +                        (maybe-integer)
> +                        "The delay in seconds before the mail syncing =
is triggered.")
> +                      (boxes
> +                        (maybe-list-of-strings)
> +                        "Mailboxes to watch.")
> +                      (prefix goimapnotify-))

You can omit the parentheses around the field-type.

> +(define (list-of-goimapnotify-accounts? lst)
> +  "List is in the form of '((file-name file-like))"
> +  (every (lambda (element)
> +           (match element
> +                  ((string ($ <goimapnotify-account>))
> +                   #t)
> +                  (_ #f)))
> +         lst))

You can replace this with:
--8<---------------cut here---------------start------------->8---
(define list-of-goimapnotify-accounts?
  (list-of goimapnotify-account?))
--8<---------------cut here---------------end--------------->8---

> +(define-configuration/no-serialization home-goimapnotify-configuration=

> +                                       (accounts
> +                                         (list-of-goimapnotify-account=
s '())
> +                                         "List of accounts that goimap=
notify should watch.
> +                                         For each account, a separate =
configuration file
> +                                         will be generated."))
> +
> +(define (home-goimapnotify-extension old-config extensions)
> +  (match-record old-config <home-goimapnotify-configuration>
> +                (accounts)
> +                (home-goimapnotify-configuration
> +                  (inherit old-config)
> +                  (accounts (append accounts
> +                                    (append-map
> +                                      home-goimapnotify-configuration-=
accounts
> +                                      extensions))))))

This looks misindented, the .dir-locals file automatically handles
this if you are using emacs.

> +
> +(define home-goimapnotify-service-type
> +  (service-type (name 'home-goimapnotify-service)
> +                (extensions
> +                  (list (service-extension
> +                          home-files-service-type
> +                          goimapnotify-files)))
> +                (compose identity)
> +                (extend home-goimapnotify-extension)
> +                (default-value (home-goimapnotify-configuration))
> +                (description "Configure goimapnotify to execute script=
s on IMAP
> +                             mailbox changes.")))

Stylistically, I'd indent this as:

--8<---------------cut here---------------start------------->8---
(define home-goimapnotify-service-type
  (service-type
   (name 'home-goimapnotify-service)
   (extensions =E2=80=A6
--8<---------------cut here---------------end--------------->8---


My 2=C2=A2!

--=20
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.


--------------1nSCjVH3KzEBNhKYYg95Fy7I--

--------------ktqh07dFjGbp4K27zTEBzkDk
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTAPCseV0HOaN0YFheobOGDL+spVQUCZVuUaQAKCRCobOGDL+sp
VWwCAQD6kYQ+nXCnGPvvjLKWDmroNSYXo7bG15CuPkqIgBvs4wEAjIg+HbbC8utF
Kce+ACMm6sPsUJuv+T10WJ6LF5PZpgM=
=Xd5Z
-----END PGP SIGNATURE-----

--------------ktqh07dFjGbp4K27zTEBzkDk--




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
Resent-From: Nils Landt <nils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 21 Nov 2023 15:26:02 +0000
Resent-Message-ID: <handler.66557.B66557.170058033522481 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Bruno Victal <mirai@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.170058033522481
          (code B ref 66557); Tue, 21 Nov 2023 15:26:02 +0000
Received: (at 66557) by debbugs.gnu.org; 21 Nov 2023 15:25:35 +0000
Received: from localhost ([127.0.0.1]:57240 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r5Sd4-0005qX-P0
	for submit <at> debbugs.gnu.org; Tue, 21 Nov 2023 10:25:35 -0500
Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]:39464)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nils@HIDDEN>) id 1r5Sd2-0005qF-P0
 for 66557 <at> debbugs.gnu.org; Tue, 21 Nov 2023 10:25:34 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:b231:465::2])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SZSqj4wtNz9t2C;
 Tue, 21 Nov 2023 16:25:21 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landt.email; s=MBO0001;
 t=1700580321;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=10DNSqGfqfhZ/xNo8KQ15ThMgRfLIYsnTOdeEpoknvY=;
 b=Ur46iqQYiiABPZpXZi2UP8g8L6xkpPi7a7n0ZCTo7wVOCNOcK/qJ5MnB2IU6J71itEdTeH
 WENugjMUX96eMyNXtpnUYHy6797adZhiVSJlRhU8XHDhzzrbKnGyvQgir7iJdmOHtBTs3G
 qUK6zshlvpv6oZVqcnUjRIFsMxl2YAkRB+tIu3HyshoEClQuhrxTDO13bdVrrXLjMOxrkl
 bafLSHme6X7updy9ZhvD68qi8347eEBV5QUFdOCs99QQp5Iq9UA29qXlyE1H/xbqdz8fUj
 9nBWWgHYGOekBsf5RHw0hYxREuZ8v1KZagT8Z0RQBakCxH16tj84Oer/Qg9ESA==
Date: Tue, 21 Nov 2023 16:25:21 +0100 (CET)
From: Nils Landt <nils@HIDDEN>
Message-ID: <656336790.399020.1700580321203@HIDDEN>
In-Reply-To: <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
 <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Priority: 3
Importance: Normal
X-Rspamd-Queue-Id: 4SZSqj4wtNz9t2C
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Thank you for the feedback, I'll work on implementing it, hopefully on the =
weekend.=20

I've already added a few comments / questions below though.

> Bruno Victal <mirai@HIDDEN> hat am 20.11.2023 18:16 CET ls,
>=20
> On 2023-10-15 15:01, Nils Landt wrote:
> > This patch adds a home service for generating goimapnotify JSON
> > configuration files.
>=20
> [=E2=80=A6]
>=20
> Not a goimapnotify user but this looks like a daemon application.
> I don't like this design much, I think goimapnotify should be launched an=
d managed
> using shepherd instead of simply exposing these files to the user.

These options can not be given as command line options, they need to be in =
a config file.
Personally I don't use shepherd, so I won't be contributing shepherd servic=
es :)

> > +@item @code{username-cmd} (type: maybe-string-or-file-like)
> > +An executable or script that retrieves your username from
> > +somewhere, we cannot pass arguments to this command from Stdin.
>=20
> I'd prefer to write it as =E2=80=9Cstdin=E2=80=9D (lowercase) or expand i=
t to =E2=80=9Cstandard input=E2=80=9D.

I think this a good change, and I'm completely fine making it. I just want =
to mention that I copied these docstrings directly from the project's readm=
e. But I see no reason why the author would capitalize it.

> > +(define (list-of-goimapnotify-accounts? lst)
> > +  "List is in the form of '((file-name file-like))"
> > +  (every (lambda (element)
> > +           (match element
> > +                  ((string ($ <goimapnotify-account>))
> > +                   #t)
> > +                  (_ #f)))
> > +         lst))
>=20
> You can replace this with:
> --8<---------------cut here---------------start------------->8---
> (define list-of-goimapnotify-accounts?
>   (list-of goimapnotify-account?))
> --8<---------------cut here---------------end--------------->8---

Wouldn't that fail because it expects '(goimapnotify-account goimapnotify-a=
ccount[...])?

> This looks misindented, the .dir-locals file automatically handles
> this if you are using emacs.

I'm using vim. The code is indented with autoindent, as mentioned on https:=
//guix.gnu.org/manual/devel/en/html_node/Vim-and-NeoVim.html . If this does=
n't match the expected indentation as implemented in Emacs, I'd be grateful=
 if you could indent this file before merging.




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Resent-From: Nils Landt <nils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 21 Nov 2023 15:31:01 +0000
Resent-Message-ID: <handler.66557.B66557.170058063223172 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: "rekado@HIDDEN" <rekado@HIDDEN>
Cc: "66557 <at> debbugs.gnu.org" <66557 <at> debbugs.gnu.org>
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.170058063223172
          (code B ref 66557); Tue, 21 Nov 2023 15:31:01 +0000
Received: (at 66557) by debbugs.gnu.org; 21 Nov 2023 15:30:32 +0000
Received: from localhost ([127.0.0.1]:57252 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r5Shr-00061g-V0
	for submit <at> debbugs.gnu.org; Tue, 21 Nov 2023 10:30:32 -0500
Received: from mout-p-103.mailbox.org ([80.241.56.161]:56158)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nils@HIDDEN>) id 1r5Shp-00061M-Pa
 for 66557 <at> debbugs.gnu.org; Tue, 21 Nov 2023 10:30:30 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:b231:465::2])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4SZSxR24XMz9svD;
 Tue, 21 Nov 2023 16:30:19 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landt.email; s=MBO0001;
 t=1700580619;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=Lj/X5hJmuzBgokY6V8FgRNO+E4WGrsUANe9IFM0I9GI=;
 b=k3OxCA5q4C78U2ykf+rVyM7nqEov1/XkA5d+HogjzCAMynPXoYCiMTbkmiWSr5Bvlc45Tq
 OB5nT5ujCLD2uKGpIk76pznAObuI+fAuTJbp1GCZ90jnpFUQRHwNOaTVkFj0uY42a4IIDS
 D1o/DhWG7wd1KJ8oSmQvAR1PC7rfZCSiDJooBpvPcTz0QbgoiXDeLF3s9Z25zEfOsQgmq7
 MGRn8x57wnGlT1tyZvJjvY7EW8appb2//vUKMqA8zuztLk+jNpUHVXKPvOuhUJLnMbsYiD
 Jt7W6CNAuzx7+9ykReT7w2S3icK99y6ZH53THGwNACfh+sdTGc9InVObmrVxmw==
Date: Tue, 21 Nov 2023 16:30:18 +0100 (CET)
From: Nils Landt <nils@HIDDEN>
Message-ID: <1205571599.400022.1700580618727@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Rspamd-Queue-Id: 4SZSxR24XMz9svD
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Thank you for your feedback Ricardo. I did not ignore you, but I did not receive a notification email, so I didn't see your message until I received a notification for Brunos reply and checked the website.

I'll (try to) incorporate your feedback as well.




Message sent to , guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Resent-From: Nils Landt <nils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: , guix-patches@HIDDEN
Resent-Date: Sun, 26 Nov 2023 10:33:02 +0000
Resent-Message-ID: <handler.66557.B66557.170099473426910 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 66557 <at> debbugs.gnu.org
Cc: Nils Landt <nils.landt@HIDDEN>, ( <paren@HIDDEN>, Andrew Tropin <andrew@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
X-Debbugs-Original-Xcc: ( <paren@HIDDEN>, Andrew Tropin <andrew@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.170099473426910
          (code B ref 66557); Sun, 26 Nov 2023 10:33:02 +0000
Received: (at 66557) by debbugs.gnu.org; 26 Nov 2023 10:32:14 +0000
Received: from localhost ([127.0.0.1]:40743 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r7CQv-0006zx-5A
	for submit <at> debbugs.gnu.org; Sun, 26 Nov 2023 05:32:14 -0500
Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]:36746)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nils@HIDDEN>) id 1r7CQr-0006zc-Ns
 for 66557 <at> debbugs.gnu.org; Sun, 26 Nov 2023 05:32:11 -0500
Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4SdQ4p20Y0z9snt;
 Sun, 26 Nov 2023 11:31:54 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landt.email; s=MBO0001;
 t=1700994714;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=qvp3XXcVHfb3ZzxIT+1SwiBtG+XyfneT2jeYzQkOXmM=;
 b=FwJ0sYkysSHA9dNodhY+z75JPuAQaZHggKI+i5sUr4wydSu7J1aS4L452QkgTJyeF7DOTX
 MHs+gOH9XfNDeZOh1EpHn+w+XQS+T/2uM3rO1PBFe+PM4mRqmRa7iWBnJqqJ8VCzRChiZl
 dwOoohJV3pW1aTHGJphKVcH28kQh3l8HuN9nYAF7G1rk6yPktSjIdIobAgQb6RByACPLy0
 vT/H0irsBz/A++dBw4PC55XVAA7GKnIoS2NlNytNsEAU/ZBIRVnk0ejcWNE1mpcp0BDtcl
 c8c6u2QcVxp/Pe9aCXNiqn8q0FDl/f36mx5PqubwrWfsLMBZ+xI8O5Jz1EsTNw==
From: Nils Landt <nils@HIDDEN>
Date: Sun, 26 Nov 2023 11:31:03 +0100
Message-ID: <dd6cf27935471a6b96dc319fde798f97547f6fa2.1700994663.git.nils@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-MBO-RS-ID: 599fd8fb332b41b8c94
X-MBO-RS-META: 4sfnu4kc3i6y9nk47op3b9t5tjzpdnry
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

From: Nils Landt <nils.landt@HIDDEN>

* gnu/home/services/mail.scm: (home-goimapnotify-configuration,
home-goimapnotify-service-type, goimapnotify-account,
goimapnotify-tls-options): New variables.
(goimapnotify-format-field, goimapnotify-serialize-field,  goimapnotify-serialize-goimapnotify-tls-options): New procedures.
* doc/guix.texi (Mail Home Services): New node.
---
 doc/guix.texi              | 139 ++++++++++++++++++++++
 gnu/home/services/mail.scm | 232 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 370 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1fd2e21608..aed15685e5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -44996,6 +44996,145 @@ Mail Home Services
 The @code{(gnu home services mail)} module provides services that help
 you set up the tools to work with emails in your home environment.
  
+@cindex goimapnotify
+@uref{https://gitlab.com/shackra/goimapnotify, goimapnotify} watches your
+mailbox(es) and executes a script on (new / deleted / updated) messages.
+
+Using @code{home-goimapnotify-configuration}, you can generate a config file
+for each account you want to watch (file name relative to @code{$HOME}), e.g.:
+
+@lisp
+(simple-service 'mail-imapnotify-config-examples
+                home-goimapnotify-service-type
+                (home-goimapnotify-configuration
+                  (accounts (list
+                              `(".config/goimapnotify/private-account.conf"
+                                ,(goimapnotify-account
+                                    (host "imap.example.org")
+                                    (port 993)
+                                    (tls #t)
+                                    (username "example")
+                                    (password-cmd
+                                      (file-append password-store
+                                        "/bin/pass my-private-email-account")
+                                    (on-new-mail
+                                      (file-append mbsync "/bin/mbsync private-account"))
+                                    (on-new-mail-post
+                                      (file-append mu "/bin/mu index"))
+                                    (boxes '("INBOX"))))
+                              `(".config/goimapnotify/work-account.conf"
+                                ,(goimapnotify-account
+                                    (host "imap.work.example.org")
+                                    (port 993)
+                                    (tls #t)
+                                    (username "example")
+                                    (password "12345")
+                                    (on-new-mail
+                                      (file-append mbsync "/bin/mbsync work-account"))
+                                    (on-new-mail-post
+                                      "notify-send 'New mail'")
+                                    (boxes '("INBOX"
+                                             "On Call")))))))))
+@end lisp
+
+Note: to utilize the config files, you need to start a separate goimapnotify
+process for each one.  Continuing the example above:
+@code{goimapnotify -conf "$HOME/.config/goimapnotify/private-account.conf"} and
+@code{goimapnotify -conf "$HOME/.config/goimapnotify/work-account.conf"}.
+
+@c %start of fragment
+@deftp {Data Type} home-goimapnotify-configuration
+Available @code{home-goimapnotify-configuration} fields are:
+
+@table @asis
+@item @code{accounts} (default: @code{()}) (type: list-of-goimapnotify-accounts)
+List of accounts that goimapnotify should watch.  For each account, a
+separate configuration file will be generated.
+@end table
+
+@end deftp
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} goimapnotify-account
+Available @code{goimapnotify-account} fields are:
+
+@table @asis
+@item @code{host} (type: maybe-string)
+Address of the IMAP server to connect to.
+
+@item @code{host-cmd} (type: maybe-string-or-file-like)
+An executable or script that retrieves your host from somewhere, we
+cannot pass arguments to this command from stdin.
+
+@item @code{port} (type: maybe-integer)
+Port of the IMAP server to connect to.
+
+@item @code{tls?} (type: maybe-boolean)
+
+Use TLS?
+
+@item @code{tls-options} (type: maybe-goimapnotify-tls-options)
+Option(s) for the TLS connection.  Currently, only one option is
+supported.
+
+@item @code{username} (type: maybe-string)
+Username for authentication.
+
+@item @code{username-cmd} (type: maybe-string-or-file-like)
+An executable or script that retrieves your username from
+somewhere, we cannot pass arguments to this command from stdin.
+
+@item @code{password} (type: maybe-string)
+Password for authentication.
+
+@item @code{password-cmd} (type:
+ maybe-string-or-file-like)
+An executable or script that retrieves your password from somewhere, we
+cannot pass arguments to this command from stdin.
+
+@item @code{xoauth2?}
+(type: maybe-boolean)
+You can also use xoauth2 instead of password based authentication by
+setting the xoauth2 option to true and the output of a tool which can
+provide xoauth2 encoded tokens in passwordCmd.  Examples:
+@uref{https://github.com/google/oauth2l,Google oauth2l} or
+@uref{https://github.com/harishkrupo/oauth2ms,xoauth2 fetcher for O36
+5}.
+
+@item @code{on-new-mail} (type: maybe-string-or-file-like)
+An executable or script to run when new mail has arrived.
+
+@item @code{on-new-mail-post} (type: maybe-string-or-file-like)
+An executable or script to run after onNewMail has ran.
+
+@item @code{wait} (type: maybe-integer)
+The delay in seconds before the mail syncing is triggered.
+
+@item @code{boxes} (type: maybe-list-of-strings)
+Mailboxes to watch.
+
+@end table
+
+@end deftp
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} goimapnotify-tls-options
+Available @code{goimapnotify-tls-options} fields are:
+
+@table @asis
+@item @code{reject-unauthorized?} (type: maybe-boolean)
+Skip verifying CA server identify?
+
+@end table
+
+@end deftp
+@c %end of fragment
+
 @cindex msmtp
 @uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail
 Transfer Protocol} client.  It sends mail to a predefined SMTP server
diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm
index 5445c82c67..b86a787963 100644
--- a/gnu/home/services/mail.scm
+++ b/gnu/home/services/mail.scm
@@ -18,15 +18,44 @@
 
 (define-module (gnu home services mail)
   #:use-module (guix gexp)
+  #:use-module (guix records)
   #:use-module (gnu services)
   #:use-module (gnu services configuration)
   #:use-module (gnu home services)
   #:use-module (gnu home services shepherd)
+  #:use-module (gnu home services utils)
   #:use-module (gnu packages mail)
+  #:use-module (gnu packages guile)
+  #:use-module (ice-9 match)
   #:use-module (ice-9 string-fun)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (home-msmtp-configuration
+  #:export (home-goimapnotify-configuration
+            home-goimapnotify-configuration-fields
+            home-goimapnotify-configuration?
+            home-goimapnotify-configuration-accounts
+            home-goimapnotify-service-type
+            goimapnotify-account
+            goimapnotify-account-fields
+            goimapnotify-account-host
+            goimapnotify-account-host-cmd
+            goimapnotify-account-port
+            goimapnotify-account-tls
+            goimapnotify-account-tls-options
+            goimapnotify-account-username
+            goimapnotify-account-username-cmd
+            goimapnotify-account-password
+            goimapnotify-account-password-cmd
+            goimapnotify-account-xoauth2
+            goimapnotify-account-on-new-mail
+            goimapnotify-account-on-new-mail-post
+            goimapnotify-account-wait
+            goimapnotify-account-boxes
+            goimapnotify-tls-options
+            goimapnotify-tls-options-fields
+            goimapnotify-tls-options-reject-unauthorized
+
+            home-msmtp-configuration
             home-msmtp-configuration?
             home-msmtp-configuration-defaults
             home-msmtp-configuration-accounts
@@ -220,3 +249,204 @@ (define home-msmtp-service-type
                 (description "Configure msmtp, a simple
 @acronym{SMTP, Simple Mail Transfer Protocol} client that can relay email
 to SMTP servers.")))
+
+; Configuration for goimapnotify from (gnu packages mail)
+
+(define-maybe string)
+(define-maybe integer)
+(define-maybe boolean)
+(define-maybe list-of-strings)
+(define-maybe string-or-file-like)
+
+(define (string-or-file-like? value)
+  (or (string? value)
+      (file-like? value)))
+
+(define (goimapnotify-format-field field-name)
+  (object->camel-case-string
+    (string-trim-right
+      (object->string field-name)
+      #\?)))
+
+(define (goimapnotify-serialize-field field-name value)
+  "This is converted to JSON later, so we don't return a string here"
+  #~(#$(goimapnotify-format-field field-name) . #$value))
+
+(define (goimapnotify-serialize-string-or-file-like field-name value)
+  (goimapnotify-serialize-string field-name value))
+
+(define (goimapnotify-maybe-serialize field-name value serialization-function)
+  (if (maybe-value-set? value)
+    (serialization-function field-name value)
+    ""))
+
+(define (goimapnotify-serialize-maybe-string-or-file-like field-name value)
+ (goimapnotify-maybe-serialize field-name value
+                               goimapnotify-serialize-string-or-file-like))
+
+(define goimapnotify-serialize-string goimapnotify-serialize-field)
+(define (goimapnotify-serialize-maybe-string field-name value)
+ (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-string))
+
+(define (goimapnotify-serialize-maybe-integer field-name value)
+ (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-integer))
+(define goimapnotify-serialize-integer goimapnotify-serialize-field)
+
+(define (goimapnotify-serialize-maybe-boolean field-name value)
+  (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-boolean))
+(define goimapnotify-serialize-boolean goimapnotify-serialize-field)
+
+(define (goimapnotify-serialize-maybe-list-of-strings field-name value)
+  (goimapnotify-maybe-serialize field-name value goimapnotify-serialize-list-of-strings))
+(define (goimapnotify-serialize-list-of-strings field-name value)
+  (goimapnotify-serialize-field field-name (list->array 1 value)))
+
+(define (goimapnotify-serialize-maybe-goimapnotify-tls-options field-name config)
+  (goimapnotify-maybe-serialize field-name config
+                                goimapnotify-serialize-goimapnotify-tls-options))
+
+(define (goimapnotify-serialize-goimapnotify-tls-options field-name config)
+  (goimapnotify-serialize-field
+    field-name
+    (prepare-configuration-for-json config goimapnotify-tls-options-fields)))
+
+(define (prepare-configuration-for-json config fields)
+  "Convert the configuration to the format expected by guile-json.
+  Unset maybe-values do not appear in the configuration file."
+  (fold
+    (lambda (field accu)
+      (let ((value ((configuration-field-getter field) config)))
+        (append accu
+          (if (maybe-value-set? value)
+            (list ((configuration-field-serializer field)
+                   (configuration-field-name field)
+                   value))
+            '()))))
+    '()
+    fields))
+
+(define-configuration goimapnotify-tls-options
+                      (reject-unauthorized?
+                        maybe-boolean
+                        "Skip verifying CA server identify?")
+                      (prefix goimapnotify-))
+
+(define-maybe goimapnotify-tls-options)
+
+; See https://gitlab.com/shackra/goimapnotify/-/blob/423f0e65350f7e042edbd2c373f252c5a0d31dc2/config.go#L46-62
+(define-configuration goimapnotify-account
+                      (host
+                        maybe-string
+                        "Address of the IMAP server to connect to.")
+                      (host-cmd
+                        maybe-string-or-file-like
+                        "An executable or script that retrieves your host from somewhere,
+                        we cannot pass arguments to this command from stdin.")
+                      (port
+                        maybe-integer
+                        "Port of the IMAP server to connect to.")
+                      (tls?
+                        maybe-boolean
+                        "Use TLS?")
+                      (tls-options
+                        maybe-goimapnotify-tls-options
+                        "Option(s) for the TLS connection. Currently, only one option is
+                        supported.")
+                      (username
+                        maybe-string
+                        "Username for authentication.")
+                      (username-cmd
+                        maybe-string-or-file-like
+                        "An executable or script that retrieves your username from
+                        somewhere, we cannot pass arguments to this command from stdin.")
+                      (password
+                        maybe-string
+                        "Password for authentication.")
+                      (password-cmd
+                        maybe-string-or-file-like
+                        "An executable or script that retrieves your password from
+                        somewhere, we cannot pass arguments to this command from stdin.")
+                      (xoauth2?
+                        maybe-boolean
+                        "You can also use xoauth2 instead of password based authentication
+                        by setting the xoauth2 option to true and the output of a tool
+                        which can provide xoauth2 encoded tokens in passwordCmd.
+                        Examples: @url{https://github.com/google/oauth2l, Google oauth2l}
+                        or
+                        @url{https://github.com/harishkrupo/oauth2ms, xoauth2 fetcher for O365}.")
+                      (on-new-mail
+                        maybe-string-or-file-like
+                        "An executable or script to run when new mail has arrived.")
+                      (on-new-mail-post
+                        maybe-string-or-file-like
+                        "An executable or script to run after on-new-mail has ran.")
+                      (wait
+                        maybe-integer
+                        "The delay in seconds before the mail syncing is triggered.")
+                      (boxes
+                        maybe-list-of-strings
+                        "Mailboxes to watch.")
+                      (prefix goimapnotify-))
+
+(define (list-of-goimapnotify-accounts? lst)
+  "List is in the form of '((file-name file-like))"
+  (every (compose goimapnotify-account? second) lst))
+
+(define-configuration/no-serialization home-goimapnotify-configuration
+                                       (accounts
+                                         (list-of-goimapnotify-accounts '())
+                                         "List of accounts that goimapnotify should watch.
+                                         For each account, a separate configuration file
+                                         will be generated."))
+
+(define (home-goimapnotify-extension old-config extensions)
+  (match-record old-config <home-goimapnotify-configuration>
+                (accounts)
+                (home-goimapnotify-configuration
+                  (inherit old-config)
+                  (accounts (append accounts
+                                    (append-map
+                                      home-goimapnotify-configuration-accounts
+                                      extensions))))))
+
+(define (goimapnotify-files config)
+  (define* (account->json account-config-and-path)
+    (match
+      account-config-and-path
+      ((path account-config)
+       (let ((prepared-config
+               (prepare-configuration-for-json
+                 account-config
+                 goimapnotify-account-fields)))
+         `((,path
+            ,(computed-file
+               (string-append
+                 "mail-imapnotify-config-"
+                 (goimapnotify-account-host account-config))
+               (with-extensions (list guile-json-4)
+                   #~(begin
+                       (use-modules (json builder))
+
+                       (with-output-to-file #$output
+                         (lambda ()
+                           (scm->json '(#$@prepared-config)
+                                      #:pretty #t))))))))))))
+
+  (match-record config <home-goimapnotify-configuration>
+                (accounts)
+                (append-map
+                  (cut account->json <>)
+                  accounts)))
+
+(define home-goimapnotify-service-type
+  (service-type
+    (name 'home-goimapnotify-service)
+    (extensions
+      (list (service-extension
+              home-files-service-type
+              goimapnotify-files)))
+    (compose identity)
+    (extend home-goimapnotify-extension)
+    (default-value (home-goimapnotify-configuration))
+    (description "Configure goimapnotify to execute scripts on IMAP
+                 mailbox changes.")))

base-commit: 513bf164592e2b44e3e556cc5099a19bd6977790
-- 
2.41.0





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
In-Reply-To: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
Resent-From: Nils Landt <nils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 26 Nov 2023 11:15:01 +0000
Resent-Message-ID: <handler.66557.B66557.170099727831773 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: "66557 <at> debbugs.gnu.org" <66557 <at> debbugs.gnu.org>
Cc: "rekado@HIDDEN" <rekado@HIDDEN>, "mirai@HIDDEN" <mirai@HIDDEN>
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.170099727831773
          (code B ref 66557); Sun, 26 Nov 2023 11:15:01 +0000
Received: (at 66557) by debbugs.gnu.org; 26 Nov 2023 11:14:38 +0000
Received: from localhost ([127.0.0.1]:40785 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r7D5y-0008GO-1B
	for submit <at> debbugs.gnu.org; Sun, 26 Nov 2023 06:14:38 -0500
Received: from mout-p-101.mailbox.org ([80.241.56.151]:37422)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nils@HIDDEN>) id 1r7D5v-0008G8-7u
 for 66557 <at> debbugs.gnu.org; Sun, 26 Nov 2023 06:14:36 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4SdR1n5dsWz9sQr;
 Sun, 26 Nov 2023 12:14:21 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landt.email; s=MBO0001;
 t=1700997261;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=XAn2LVxhRgX3Agq1Wm9pu+XR6yhVy1XLvMyQPH0ubjs=;
 b=U5LBIkwPFC4NC8tqehv+xvY2LewUaB82LMkZoCDVQbNdyU1LmC/iv0q+dtkl1bkGYZXd8B
 oVYhwudUx4smEbI8wzGSNU9+vFmh9SLc4hFW+8xJ77h2zfNA1vLkuIM+6nIdVj3HSVhKDI
 fwC1P3M8FfwXam3WZylRlZOidloobR6JdNcV14aJPPuEdFqcRec/5r6i1s+fs+1Q7PKxaX
 CvzUelUZvsSh9IlD8OyTm6GfbqNAs4iIs5HUfzHPuA1hO5cD2RFk0pSXQwbLWqmlFxgf7a
 hShYwff6LS3o+Y1DbtKiedton1quZbs3EhZ24nkVmGcnHb0Nf7gPWod2tz0ZRg==
Date: Sun, 26 Nov 2023 12:14:20 +0100 (CET)
From: Nils Landt <nils@HIDDEN>
Message-ID: <1635724009.68147.1700997260830@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Priority: 3
Importance: Normal
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hello,

I have pushed a new version.
Compared to the version you reviewed, I made the following changes:
- docs: Stdin -> stdin
- docs: use file-append for "pass" example
- docs: re-add trailing whitespace
- rework filter + map to use fold instead
- update link to upstream config documentation from master to current commi=
t
- ignore first element in list-of-goimapnotify-accounts?
- add question mark suffix to boolean fields (e.g. tls -> tls?)
- fix "on-new-mail" option in docstring
- remove parentheses around configuration field types

Lastly, some comments on review requests I was unable to implement.

Ricardo:
> So I think it would be better to let these fields accept command lists.
> FILE-APPEND should only join the package value with the file name of the
> executable, but not include any arguments.

I did not understand what this meant. Do you have any examples? I implement=
ed your second suggestion of using file-append for pass instead.

> Could this be (cons (goimapnotify-format-field field-name) value)
> instead?  I don=E2=80=99t think we need this wrapping and unwrapping with=
 G-exp
> syntax.

This results in e.g. ("boxes" . #("INBOX")) , leading to a syntax error in =
the generated guile script. I'm open to suggestions here.

Bruno:
> This isn't needed, fields whose maybe-values are unset don't call the
> serializing procedures.

combined with

> You can use 'serialize-configuration' instead which accounts for the unse=
t maybe-values.

I put some time into this, but I don't see how serialize-configuration, whi=
ch returns a gexp including string-append, could be used to turn a configur=
ation record into the format required by guile-json.




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
Resent-From: Bruno Victal <mirai@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 28 Nov 2023 20:39:01 +0000
Resent-Message-ID: <handler.66557.B66557.170120389215372 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.170120389215372
          (code B ref 66557); Tue, 28 Nov 2023 20:39:01 +0000
Received: (at 66557) by debbugs.gnu.org; 28 Nov 2023 20:38:12 +0000
Received: from localhost ([127.0.0.1]:47815 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r84qS-0003zs-Hi
	for submit <at> debbugs.gnu.org; Tue, 28 Nov 2023 15:38:12 -0500
Received: from smtpm2.myservices.hosting ([185.26.105.233]:35424)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1r84qP-0003zh-Ur
 for 66557 <at> debbugs.gnu.org; Tue, 28 Nov 2023 15:38:11 -0500
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm2.myservices.hosting (Postfix) with ESMTP id 0ED8920414;
 Tue, 28 Nov 2023 21:38:00 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 5865380067;
 Tue, 28 Nov 2023 21:38:00 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id Qx8m3BVRBhyz; Tue, 28 Nov 2023 21:37:59 +0100 (CET)
Received: from [192.168.1.116] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id B3E9380060;
 Tue, 28 Nov 2023 21:37:59 +0100 (CET)
Message-ID: <d5eedb15-077d-4a67-9337-9dea96e0e46a@HIDDEN>
Date: Tue, 28 Nov 2023 20:37:58 +0000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
 <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
 <656336790.399020.1700580321203@HIDDEN>
From: Bruno Victal <mirai@HIDDEN>
In-Reply-To: <656336790.399020.1700580321203@HIDDEN>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------rc0y1AQv0xTLU6zsF5hhgLYz"
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------rc0y1AQv0xTLU6zsF5hhgLYz
Content-Type: multipart/mixed; boundary="------------01gKkOXvl3LzjnTe52lX0lnS";
 protected-headers="v1"
From: Bruno Victal <mirai@HIDDEN>
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Message-ID: <d5eedb15-077d-4a67-9337-9dea96e0e46a@HIDDEN>
Subject: Re: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
 <d279a547-7f5c-4244-8f78-ad0fb98cbe2c@HIDDEN>
 <656336790.399020.1700580321203@HIDDEN>
In-Reply-To: <656336790.399020.1700580321203@HIDDEN>

--------------01gKkOXvl3LzjnTe52lX0lnS
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Nils,

On 2023-11-21 15:25, Nils Landt wrote:
>> Bruno Victal <mirai@HIDDEN> hat am 20.11.2023 18:16 CET ls,
>> On 2023-10-15 15:01, Nils Landt wrote:
>>> +(define (list-of-goimapnotify-accounts? lst)
>>> +  "List is in the form of '((file-name file-like))"
>>> +  (every (lambda (element)
>>> +           (match element
>>> +                  ((string ($ <goimapnotify-account>))
>>> +                   #t)
>>> +                  (_ #f)))
>>> +         lst))
>>
>> You can replace this with:
>> --8<---------------cut here---------------start------------->8---
>> (define list-of-goimapnotify-accounts?
>>   (list-of goimapnotify-account?))
>> --8<---------------cut here---------------end--------------->8---
>=20
> Wouldn't that fail because it expects '(goimapnotify-account goimapnoti=
fy-account[...])?

Right, it should be something like:

--8<---------------cut here---------------start------------->8---
(define list-of-goimapnotify-accounts?
  (list-of (match-lambda ((? string?) (? goimapnotify-account?)))))
--8<---------------cut here---------------end--------------->8---

--=20
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.

--------------01gKkOXvl3LzjnTe52lX0lnS--

--------------rc0y1AQv0xTLU6zsF5hhgLYz
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTAPCseV0HOaN0YFheobOGDL+spVQUCZWZPpwAKCRCobOGDL+sp
VWzuAQDVlw9Bvl7PTOXbMPqHnpKJnI30bTUbL5Cbp8fvM0B/zwD+MtH9P8pv8Mz+
dz46ffftuIfAqhLqTFCzDaNuK8djvgE=
=exvL
-----END PGP SIGNATURE-----

--------------rc0y1AQv0xTLU6zsF5hhgLYz--




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#66557] [PATCH] home: services: Add goimapnotify service.
Resent-From: Bruno Victal <mirai@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 29 Nov 2023 17:21:02 +0000
Resent-Message-ID: <handler.66557.B66557.17012784508948 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66557
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Received: via spool by 66557-submit <at> debbugs.gnu.org id=B66557.17012784508948
          (code B ref 66557); Wed, 29 Nov 2023 17:21:02 +0000
Received: (at 66557) by debbugs.gnu.org; 29 Nov 2023 17:20:50 +0000
Received: from localhost ([127.0.0.1]:50998 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8OF0-0002KG-7r
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 12:20:50 -0500
Received: from smtpm2.myservices.hosting ([185.26.105.233]:42252)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1r8OEy-0002K6-4x
 for 66557 <at> debbugs.gnu.org; Wed, 29 Nov 2023 12:20:48 -0500
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm2.myservices.hosting (Postfix) with ESMTP id A0E9F20A0B;
 Wed, 29 Nov 2023 18:20:38 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id EE46380067;
 Wed, 29 Nov 2023 18:20:34 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id fCZvE5ygXrNY; Wed, 29 Nov 2023 18:20:34 +0100 (CET)
Received: from [192.168.1.116] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 61FCA80060;
 Wed, 29 Nov 2023 18:20:34 +0100 (CET)
Message-ID: <52947fbf-42c2-44e5-adf4-0b1bd66f56c0@HIDDEN>
Date: Wed, 29 Nov 2023 17:20:09 +0000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
 <1635724009.68147.1700997260830@HIDDEN>
From: Bruno Victal <mirai@HIDDEN>
In-Reply-To: <1635724009.68147.1700997260830@HIDDEN>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------I9T01YonLOdKc8NXXbadyF8S"
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------I9T01YonLOdKc8NXXbadyF8S
Content-Type: multipart/mixed; boundary="------------igvkadOhEDLvz9lzF4WijUYt";
 protected-headers="v1"
From: Bruno Victal <mirai@HIDDEN>
To: Nils Landt <nils@HIDDEN>
Cc: 66557 <at> debbugs.gnu.org
Message-ID: <52947fbf-42c2-44e5-adf4-0b1bd66f56c0@HIDDEN>
Subject: Re: [bug#66557] [PATCH] home: services: Add goimapnotify service.
References: <c9d8798670448a18779e3c24b9b8a88902942936.1697378478.git.nils@HIDDEN>
 <1635724009.68147.1700997260830@HIDDEN>
In-Reply-To: <1635724009.68147.1700997260830@HIDDEN>

--------------igvkadOhEDLvz9lzF4WijUYt
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Nils,

On 2023-11-26 11:14, Nils Landt wrote:
> Bruno:
>> This isn't needed, fields whose maybe-values are unset don't call the
>> serializing procedures.
>=20
> combined with
>=20
>> You can use 'serialize-configuration' instead which accounts for the u=
nset maybe-values.
>=20
> I put some time into this, but I don't see how serialize-configuration,=
 which returns a gexp including string-append, could be used to turn a co=
nfiguration record into the format required by guile-json.

Right, I missed that you are synthesizing a list for scm->json,
you will need to make use of the lower-level transducers in
(gnu services configuration).
The fstrim-service-type in (gnu services linux) provides a simple
example of its use though for your case you might be looking at
something like:

--8<---------------cut here---------------start------------->8---
;; note: untested snippet

(define (goimapnotify-files config)
  (match-record config <home-goimapnotify-configuration>
                (accounts)
    (map (match-lambda
           ((path account)
            (list path
                  (computed-file
                   (string-append "mail-imapnotify-config-"
                                  (goimapnotify-account-host account))
                   (with-extensions (list guile-json-4)
                     #~(begin
                         (use-modules (json builder))
                         (with-output-to-file #$output
                           (lambda ()
                             (scm->json
                              (list #$@(list-transduce
                                        (base-transducer account)
                                        rcons
                                        goimapnotify-account-fields)))
                             #:pretty #t))))))))
         accounts)))
--8<---------------cut here---------------end--------------->8---

--=20
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.

--------------igvkadOhEDLvz9lzF4WijUYt--

--------------I9T01YonLOdKc8NXXbadyF8S
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTAPCseV0HOaN0YFheobOGDL+spVQUCZWdyywAKCRCobOGDL+sp
Vc+fAQCgT2X2e25LJsMdp1B9SNr2SLSdurGU35QuEST69UsfywEAtWp6Xes5PE+h
x4v92ETD+vm8kbYQpyIN6DWnaOIR1wQ=
=eMJU
-----END PGP SIGNATURE-----

--------------I9T01YonLOdKc8NXXbadyF8S--





Last modified: Wed, 29 Nov 2023 17:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.