From unknown Sat Jun 21 10:41:39 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#62969 <62969@debbugs.gnu.org> To: bug#62969 <62969@debbugs.gnu.org> Subject: Status: [PATCH] home: Add msmtp service. Reply-To: bug#62969 <62969@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:41:39 +0000 retitle 62969 [PATCH] home: Add msmtp service. reassign 62969 guix-patches submitter 62969 Tanguy Le Carrour severity 62969 normal tag 62969 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 10:43:16 2023 Received: (at submit) by debbugs.gnu.org; 20 Apr 2023 14:43:16 +0000 Received: from localhost ([127.0.0.1]:38493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppVVD-0001Ld-8S for submit@debbugs.gnu.org; Thu, 20 Apr 2023 10:43:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:39822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppVV9-0001LS-8S for submit@debbugs.gnu.org; Thu, 20 Apr 2023 10:43:13 -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 ) id 1ppVV8-0004U3-FC for guix-patches@gnu.org; Thu, 20 Apr 2023 10:43:10 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppVV3-00060b-Ng for guix-patches@gnu.org; Thu, 20 Apr 2023 10:43:10 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id 9C641FF80E; Thu, 20 Apr 2023 14:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1682001778; 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=SL3RDr/qmSnadDCjGRybNGIo8pHLrz539jB/k2k8F9s=; b=pO4TbeYC0HLMDWWmpnco9qtTqX5VBncti7sCFpffcNrHIMsJJbarxGZh3EIIP0Oj2KFcCt OB2wjvTUKRwEl8rcm/UitMcfSWdUp35Q1DQE5NL7mSQW8YaSOCiGhCJD6WVXPnZOESc3oN 9jnSw8cSwoV3AERahjG7y2CgW6L2NPROd/9XAKH+4IJKpM5mBPBAHkpogF4/gypjzQk6c8 FtHvoKcARHZMpZcQ4n5uy1p37DPtIpHg35lXQWDlV9h9ySZlmChTXugBzO2KjDDJHAWgPg NTNnjjts/PXP1TK5kfy0yfq+gwlAjFOH6+ekcv15x9VwiaI8EQWA7NuUmaGUCw== From: Tanguy Le Carrour To: guix-patches@gnu.org Subject: [PATCH] home: Add msmtp service. Date: Thu, 20 Apr 2023 16:42:30 +0200 Message-Id: <20230420144230.9392-1-tanguy@bioneland.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.199; envelope-from=tanguy@bioneland.org; helo=relay9-d.mail.gandi.net 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: Tanguy Le Carrour X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Hi Guix, It's my first time 1) submitting a patch for a home service and 2) editing a `.texi` file, so please be understanding and… pay special attention! :-) Be aware that the code contains two FIXMEs: - one that I don't know how to solve ``` + ;; FIXME `In procedure every: Wrong type argument: #` + ;(every msmtp-account? lst)) ``` - one that is a cosmetic change, and probabliy doesn't need fixing ``` + ; FIXME Begin each line inside an account section with a space. + #~(string-append #$(serialize-configuration value msmtp-configuration-fields))) ``` And the documentation could probably be more detailed! This being said… thanks for reading! * gnu/home/services/mail.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Mailing): New node. --- doc/guix.texi | 95 ++++++++++++++++++ gnu/home/services/mail.scm | 196 +++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 3 files changed, 292 insertions(+) create mode 100644 gnu/home/services/mail.scm diff --git a/doc/guix.texi b/doc/guix.texi index adb1975935..5a1e215d17 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -114,6 +114,7 @@ Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@* Copyright @copyright{} 2023 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby +Copyright @copyright{} 2023 Tanguy Le Carrour Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -41880,6 +41881,7 @@ services)}. * Guix: Guix Home Services. Services for Guix. * Fonts: Fonts Home Services. Services for managing User's fonts. * Sound: Sound Home Services. Dealing with audio. +* Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. @end menu @@ -43082,6 +43084,99 @@ Stopping the Shepherd service turns off broadcasting. This is the multicast address used by default by the two services above. @end defvar +@node Mail Home Services +@subsection Mail Home Services + +@cindex msmtp +@uref{https://marlam.de/msmtp, MSMTP} is an SMTP client. + +@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: raw-configuration-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 + +@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 + +@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{logfile} (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{passwordeval} (type: maybe-string) +Set the password for authentication to the output (stdout) of the +command cmd. + +@item @code{extra-content} (default: @code{""}) (type: raw-configuration-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 + + @node Messaging Home Services @subsection Messaging Home Services diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm new file mode 100644 index 0000000000..b31f68d2ca --- /dev/null +++ b/gnu/home/services/mail.scm @@ -0,0 +1,196 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2023 Tanguy Le Carrour +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services mail) + #:use-module (guix gexp) + #:use-module (gnu packages) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu home services) + #:use-module (gnu home services shepherd) + #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-26) + #:export (home-msmtp-configuration + home-msmtp-configuration? + home-msmtp-service-type + msmtp-account + msmtp-configuration)) + +(define raw-configuration-string? string?) + +(define-maybe string) +(define-maybe boolean) +(define-maybe integer) + +;; Serialization of 'msmtp'. +(define (uglify-symbol field-name) + (let* ((name (symbol->string field-name)) + (ugly-name (string-replace-substring name "-" "_"))) + (if (string-suffix? "?" ugly-name) + (string-drop-right ugly-name 1) + ugly-name))) + +(define (configuration-serialize-maybe-string field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " #$value "\n") + "")) + +(define (configuration-serialize-maybe-integer field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (number->string #$value) "\n") + "")) + +(define (configuration-serialize-maybe-boolean field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (if #$value "on" "off") "\n") + "")) + +(define (configuration-serialize-raw-configuration-string field-name value) + #~(if #$(string=? value "") "" (string-append #$value "\n"))) + +(define (account-serialize-name field-name value) + #~(string-append "\naccount " #$value "\n")) + +(define (account-serialize-string field-name value) + #~(string-append " " #$(uglify-symbol field-name) " " #$value "\n")) + +(define (account-serialize-string field-name value) + #~(string-append " " #$(uglify-symbol field-name) " " #$value "\n")) + +(define (account-serialize-msmtp-configuration field-name value) + ; FIXME Begin each line inside an account section with a space. + #~(string-append #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-configuration-serialize-list-of-msmtp-accounts field-name value) + #~(string-append #$@(map (cut serialize-configuration <> msmtp-account-fields) + value))) + +(define (home-configuration-serialize-msmtp-configuration field-name value) + #~(string-append "defaults\n" + #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-configuration-serialize-string field-name value) + #~(string-append #$(uglify-symbol field-name) " " #$value "\n")) + +(define (home-configuration-serialize-default-account field-name value) + #~(if #$(maybe-value-set? value) + (string-append "\naccount default : " #$value "\n") + "")) + +(define (home-configuration-serialize-raw-configuration-string field-name value) + #~(if #$(string=? value "") "" (string-append #$value "\n"))) + +;; Configuration of 'msmtp'. +(define (list-of-msmtp-accounts? lst) + ;; FIXME `In procedure every: Wrong type argument: #` + ;(every msmtp-account? lst)) + #t) + +;; Source . +(define-configuration msmtp-configuration + (auth? + maybe-boolean + "Enable or disable authentication.") + (tls? + maybe-boolean + "Enable or disable TLS (also known as SSL) for secured connections.") + (tls-starttls + maybe-boolean + "Choose the TLS variant: start TLS from within the session (‘on’, default), +or tunnel the session through TLS (‘off’).") + (tls-trust-file + maybe-string + "Activate server certificate verification using a list of +trusted Certification Authorities (CAs).") + (logfile + maybe-string + "Enable logging to the specified file. An empty argument disables logging. +The file name ‘-’ directs the log information to standard output.") + (host + maybe-string + "The SMTP server to send the mail to.") + (port + 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\").") + (user + maybe-string + "Set the user name for authentication.") + (from + maybe-string + "Set the envelope-from address.") + (passwordeval + maybe-string + "Set the password for authentication to the output (stdout) of the command cmd.") + (extra-content + (raw-configuration-string "") + "Extra content appended as-is to the configuration block. Run +@command{man msmtp} for more information about the configuration file +format.") + (prefix configuration-)) + +(define-configuration msmtp-account + (name + (string) + "The unique name of the account." + (serializer account-serialize-name)) + (configuration + (msmtp-configuration) + "The configuration for this given account.") + (prefix account-)) + +(define-configuration home-msmtp-configuration + (defaults + (msmtp-configuration (msmtp-configuration)) + "The configuration that will be set as default for all accounts.") + (accounts + (list-of-msmtp-accounts '()) + "A list of @code{msmtp-account} records which contain +information about all your accounts.") + (default-account + maybe-string + "Set the default account." + (serializer home-configuration-serialize-default-account)) + (extra-content + (raw-configuration-string "") + "Extra content appended as-is to the configuration file. Run +@command{man msmtp} for more information about the configuration file +format.") + (prefix home-configuration-)) + +(define (home-msmtp-files-service config) + (list + `(".config/msmtp/config" + ,(mixed-text-file "config" + (serialize-configuration config home-msmtp-configuration-fields))))) + +(define (home-msmtp-profile-service config) + (specifications->packages (list "msmtp"))) + +(define home-msmtp-service-type + (service-type (name 'home-msmtp) + (extensions + (list + (service-extension + home-profile-service-type + home-msmtp-profile-service) + (service-extension + home-files-service-type + home-msmtp-files-service))) + (default-value (home-msmtp-configuration)) + (description "Configures msmtp."))) diff --git a/gnu/local.mk b/gnu/local.mk index 01ffe3fdb6..3f57ca3c98 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -93,6 +93,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/fontutils.scm \ %D%/home/services/gnupg.scm \ %D%/home/services/guix.scm \ + %D%/home/services/mail.scm \ %D%/home/services/media.scm \ %D%/home/services/messaging.scm \ %D%/home/services/pm.scm \ -- 2.39.2 From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 12:37:09 2023 Received: (at 62969) by debbugs.gnu.org; 20 Apr 2023 16:37:09 +0000 Received: from localhost ([127.0.0.1]:38594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppXHQ-0004tB-Sl for submit@debbugs.gnu.org; Thu, 20 Apr 2023 12:37:09 -0400 Received: from smtpm1.myservices.hosting ([185.26.105.232]:40236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppXHO-0004t2-21 for 62969@debbugs.gnu.org; Thu, 20 Apr 2023 12:37:07 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm1.myservices.hosting (Postfix) with ESMTP id BEAEA205C3; Thu, 20 Apr 2023 18:37:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 65FBB8009A; Thu, 20 Apr 2023 18:37:04 +0200 (CEST) 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 tOZB9B-xqsJv; Thu, 20 Apr 2023 18:37:03 +0200 (CEST) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id BB58780098; Thu, 20 Apr 2023 18:37:03 +0200 (CEST) Message-ID: <4f8624a0-31fe-1ea5-733a-b2e1917291b4@makinata.eu> Date: Thu, 20 Apr 2023 17:36:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [bug#62969] [PATCH] home: Add msmtp service. Content-Language: en-US To: Tanguy Le Carrour References: <20230420144230.9392-1-tanguy@bioneland.org> From: Bruno Victal In-Reply-To: <20230420144230.9392-1-tanguy@bioneland.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hi Tanguy, On 2023-04-20 15:42, Tanguy Le Carrour wrote: > - one that I don't know how to solve > ``` > + ;; FIXME `In procedure every: Wrong type argument: #` > + ;(every msmtp-account? lst)) > ``` Place this after '(define-configuration mstmp-account ...)'. You might want to place this block before '(define-configuration msmtp-configuration ...)'. > +@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: raw-configuration-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 You should preserve the @c lines from configuration->documentation to make it clear that the block of text was generated. > + > +(define-module (gnu home services mail) > + #:use-module (guix gexp) > + #:use-module (gnu packages) > + #:use-module (gnu services) > + #:use-module (gnu services configuration) > + #:use-module (gnu home services) > + #:use-module (gnu home services shepherd) > + #:use-module (ice-9 string-fun) > + #:use-module (srfi srfi-26) > + #:export (home-msmtp-configuration > + home-msmtp-configuration? > + home-msmtp-service-type > + msmtp-account > + msmtp-configuration)) You should export the accessors for the fields. You can use this snippet within 'guix repl' to automate the typing for you: --8<---------------cut here---------------start------------->8--- (define (helper-configuration-exports fields) (map (lambda (s) (let* ((f (compose object->string configuration-field-getter)) (g (compose cadr string-tokenize)) (s* ((compose g f) s))) (string->symbol (substring s* 1 (string-contains s* "-procedure"))))) fields)) (define (helper-formatted-exports fields) (format #t "~{~a~%~}" (helper-configuration-exports fields))) --8<---------------cut here---------------end--------------->8--- Example usage: --8<---------------cut here---------------start------------->8--- ;; paste snippet above into repl scheme@(guix-user)> ,m (gnu services audio) scheme@(gnu services audio)> (helper-formatted-exports mpd-configuration-fields) mpd-configuration-user mpd-configuration-group mpd-configuration-shepherd-requirement mpd-configuration-environment-variables mpd-configuration-log-file mpd-configuration-log-level mpd-configuration-music-directory mpd-configuration-music-dir mpd-configuration-playlist-directory mpd-configuration-playlist-dir mpd-configuration-db-file mpd-configuration-state-file mpd-configuration-sticker-file mpd-configuration-default-port mpd-configuration-endpoints mpd-configuration-address mpd-configuration-database mpd-configuration-partitions mpd-configuration-neighbors mpd-configuration-inputs mpd-configuration-archive-plugins mpd-configuration-input-cache-size mpd-configuration-decoders mpd-configuration-resampler mpd-configuration-filters mpd-configuration-outputs mpd-configuration-playlist-plugins mpd-configuration-extra-options $1 = #t --8<---------------cut here---------------end--------------->8--- > + > +(define raw-configuration-string? string?) This isn't necessary, continued below. [1] > + > +(define (configuration-serialize-maybe-string field-name value) > + #~(if #$(maybe-value-set? value) > + (string-append #$(uglify-symbol field-name) " " #$value "\n") > + ""))> + > +(define (configuration-serialize-maybe-integer field-name value) > + #~(if #$(maybe-value-set? value) > + (string-append #$(uglify-symbol field-name) " " (number->string #$value) "\n") > + "")) > + > +(define (configuration-serialize-maybe-boolean field-name value) > + #~(if #$(maybe-value-set? value) > + (string-append #$(uglify-symbol field-name) " " (if #$value "on" "off") "\n") > + "")) You don't have to perform the maybe-value-set? checks, it is automatically done for you. The only cases where this isn't true is if you explicitly override the serializer in define-configuration. [2] > +(define (account-serialize-string field-name value) > + #~(string-append " " #$(uglify-symbol field-name) " " #$value "\n")) > + > +(define (account-serialize-string field-name value) > + #~(string-append " " #$(uglify-symbol field-name) " " #$value "\n")) Duplicated? > + > +(define (account-serialize-msmtp-configuration field-name value) > + ; FIXME Begin each line inside an account section with a space. > + #~(string-append #$(serialize-configuration value msmtp-configuration-fields))) This doesn't do anything and since it's a cosmetic change I'd just ignore it, since the file is managed with guix anyways. > +(define (home-configuration-serialize-default-account field-name value) > + #~(if #$(maybe-value-set? value) > + (string-append "\naccount default : " #$value "\n") > + "")) See [2] above. > +;; Source . > +(define-configuration msmtp-configuration > + (auth? > + maybe-boolean > + "Enable or disable authentication.") > + (tls? > + maybe-boolean > + "Enable or disable TLS (also known as SSL) for secured connections.") > + (tls-starttls > + maybe-boolean > + "Choose the TLS variant: start TLS from within the session (‘on’, default), > +or tunnel the session through TLS (‘off’).") > + (tls-trust-file > + maybe-string > + "Activate server certificate verification using a list of > +trusted Certification Authorities (CAs).") > + (logfile > + maybe-string > + "Enable logging to the specified file. An empty argument disables logging. > +The file name ‘-’ directs the log information to standard output.") > + (host > + maybe-string > + "The SMTP server to send the mail to.") > + (port > + 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\").") > + (user > + maybe-string > + "Set the user name for authentication.") > + (from > + maybe-string > + "Set the envelope-from address.") > + (passwordeval > + maybe-string > + "Set the password for authentication to the output (stdout) of the command cmd.") > + (extra-content > + (raw-configuration-string "") > + "Extra content appended as-is to the configuration block. Run > +@command{man msmtp} for more information about the configuration file > +format.") Instead of defining a raw-configuration-string? predicate, simply use string? and set the serializer to '(serializer my-custom-string-serializer)' or '(serializer (lambda ...))'. [1] > + (prefix configuration-)) These are poor prefix choices for a module named (gnu home services mail). If it were (gnu home services msmtp) or (gnu home services mail msmtp) it would be acceptable but a module named (gnu home services mail) is expected to eventually contain multiple services that have to co-exist. These prefixes are too non-specific and confusion prone for such circumstances. I'd set this to (prefix msmtp-configuration-). (the same logic applies to the remaining (prefix ...) lines) > + > +(define-configuration msmtp-account > + (name > + (string) > + "The unique name of the account." > + (serializer account-serialize-name)) > + (configuration > + (msmtp-configuration) > + "The configuration for this given account.") > + (prefix account-)) > + > +(define-configuration home-msmtp-configuration > + (defaults > + (msmtp-configuration (msmtp-configuration)) > + "The configuration that will be set as default for all accounts.") > + (accounts > + (list-of-msmtp-accounts '()) > + "A list of @code{msmtp-account} records which contain > +information about all your accounts.") > + (default-account > + maybe-string > + "Set the default account." > + (serializer home-configuration-serialize-default-account)) > + (extra-content > + (raw-configuration-string "") > + "Extra content appended as-is to the configuration file. Run > +@command{man msmtp} for more information about the configuration file > +format.") > + (prefix home-configuration-)) You might want to separate each field with a space to make things easier to read but this is optional. Cheers, Bruno From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 23 13:10:29 2023 Received: (at 62969) by debbugs.gnu.org; 23 Apr 2023 17:10:29 +0000 Received: from localhost ([127.0.0.1]:46902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqdEK-0000ne-VS for submit@debbugs.gnu.org; Sun, 23 Apr 2023 13:10:29 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:43487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqdEF-0000nL-AX for 62969@debbugs.gnu.org; Sun, 23 Apr 2023 13:10:27 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id DCD81240003; Sun, 23 Apr 2023 17:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1682269817; 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=ZauskUDCZCuaAPW5eyLhpF5SHYG40mrFyL537YbkF+Q=; b=cvB3bzA1QOCp0ndIg0XPPcuo38NBciD7tWO/2379XCHBSbC0CFk7QlnbAK1VwauKieE9Hf f63Vj8VL+TTvEpLUkiMjbIeh1P9oTdXacmUuCcsZhqy4mhPLntieTqmYngcZ1LkgawQm5S K3V8ZCtKDaeDkopdb5Uc+//uxtJBtClGleZhbO3/AlQyO6rfAFXMy/PbjkW0DSWixm9mXS zA+8PXR9ou5529BvuDOuUlNHSeEDylGsD65nwnoI8HvZ40olucOPhzRUZWLu7UedzcLmHk MCLAnDbrTtCxCbVZHzPNCw+6D83BCT/8NuT2rGKdvh38S6YIW6bXSZcd7Oom4A== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable References: <20230420144230.9392-1-tanguy@bioneland.org> <4f8624a0-31fe-1ea5-733a-b2e1917291b4@makinata.eu> Subject: Re: [bug#62969] [PATCH] home: Add msmtp service. From: Tanguy LE CARROUR To: Bruno Victal In-Reply-To: <4f8624a0-31fe-1ea5-733a-b2e1917291b4@makinata.eu> Date: Sun, 23 Apr 2023 19:10:15 +0200 Message-ID: <168226981597.13515.12105199384744750840@localhost> User-Agent: alot/0.10 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi Bruno, Thank you so much for you comments! I've applied (almost, see below) all of your suggestions and I will send a = v2. Quoting Bruno Victal (2023-04-20 18:36:59) > On 2023-04-20 15:42, Tanguy Le Carrour wrote: > > +(define (configuration-serialize-maybe-string field-name value) > > + #~(if #$(maybe-value-set? value) > > + (string-append #$(uglify-symbol field-name) " " #$value "\n") > > + ""))> + > > +(define (configuration-serialize-maybe-integer field-name value) > > + #~(if #$(maybe-value-set? value) > > + (string-append #$(uglify-symbol field-name) " " (number->string = #$value) "\n") > > + "")) > > + > > +(define (configuration-serialize-maybe-boolean field-name value) > > + #~(if #$(maybe-value-set? value) > > + (string-append #$(uglify-symbol field-name) " " (if #$value "on"= "off") "\n") > > + "")) > You don't have to perform the maybe-value-set? checks, it is automaticall= y done for you. > The only cases where this isn't true is if you explicitly override the se= rializer in > define-configuration. [2] This is the only thing I can't figure out how to make work?! When I remove the `(if #$(maybe-value-set? value) =E2=80=A6)` I get the following error: ``` Backtrace: 10 (primitive-load "/gnu/store/ajcf46q8yr9sb9n90psa5ay96jw?") In ice-9/ports.scm: 433:17 9 (call-with-output-file _ _ #:binary _ #:encoding _) In ice-9/eval.scm: 159:9 8 (_ #(#(#) #)) 155:9 7 (_ #(#(#) #)) 173:39 6 (_ #(#(#) #)) 159:9 5 (_ #(#(#) #)) 173:55 4 (_ #(#(#) #)) 173:55 3 (_ #(#(#) #)) 279:15 2 (_ #(#(#) #)) 223:20 1 (proc #(#(#) #)) In unknown file: 0 (%resolve-variable (7 . %unset-marker%) #) ERROR: In procedure %resolve-variable: Unbound variable: %unset-marker% ``` > > + (prefix configuration-)) > These are poor prefix choices for a module named (gnu home services mail). > If it were (gnu home services msmtp) or (gnu home services mail msmtp) it= would be acceptable > but a module named (gnu home services mail) is expected to eventually con= tain multiple services that > have to co-exist. These prefixes are too non-specific and confusion prone= for such circumstances. >=20 > I'd set this to (prefix msmtp-configuration-). (the same logic applies to= the remaining (prefix ...) lines) I totally agree! You guessed correctly, this home service was living inside `(bioneland home services msmtp)`, so the naming seemed to make sense at the time, but not any more! Thanks again for your time and help! --=20 Tanguy From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 23 13:12:56 2023 Received: (at 62969) by debbugs.gnu.org; 23 Apr 2023 17:12:56 +0000 Received: from localhost ([127.0.0.1]:46930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqdGh-0000st-Tp for submit@debbugs.gnu.org; Sun, 23 Apr 2023 13:12:56 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:55249) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqdGf-0000sb-TR for 62969@debbugs.gnu.org; Sun, 23 Apr 2023 13:12:55 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id 3F2ED20007; Sun, 23 Apr 2023 17:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1682269967; 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=C9bCfE1Az/hhR3M+gCPlHidxSfle2VzUVD48EQ7puuM=; b=he1ZodKrpGKXxbNXYJmHdjNN4MHTT68ZIN/rCbOqvyOikmh32EpEf+8qvYXobZRocynjz3 f4egVYx66Q/NRq4XSLSQBcR3UV5yA8RdCKxN/woYIm4zUlQ6nlF9WSZ7VVMCbiRKpBku7A qmSe3eRnymqRzDVpqmhr+OEFxb98FWdlOadY9FsJlbZ9j8u1Y0p23LOaZ4bYlInvDkOmOm ENguyVPb9e4iODZJFGZuqptHqdU01yHcQy6z9RjBC4+YCC2TYyHpw1hJ2tc8uOhkn5o+Z6 M1SCJdLxOzB5XoMAaeQurYyZG7ld6TjnsnAuGupHQztTCOv6ffVohx7FftT19w== From: Tanguy Le Carrour To: 62969@debbugs.gnu.org Subject: [PATCH v2] home: Add msmtp service. Date: Sun, 23 Apr 2023 19:12:17 +0200 Message-Id: <20230423171217.14894-1-tanguy@bioneland.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62969 Cc: mirai@makinata.eu, Tanguy Le Carrour X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * gnu/home/services/mail.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Mailing): New node. --- doc/guix.texi | 106 ++++++++++++++++++ gnu/home/services/mail.scm | 219 +++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 3 files changed, 326 insertions(+) create mode 100644 gnu/home/services/mail.scm diff --git a/doc/guix.texi b/doc/guix.texi index adb1975935..78efa822f9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -114,6 +114,7 @@ Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@* Copyright @copyright{} 2023 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby +Copyright @copyright{} 2023 Tanguy Le Carrour Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -41880,6 +41881,7 @@ services)}. * Guix: Guix Home Services. Services for Guix. * Fonts: Fonts Home Services. Services for managing User's fonts. * Sound: Sound Home Services. Dealing with audio. +* Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. @end menu @@ -43082,6 +43084,110 @@ Stopping the Shepherd service turns off broadcasting. This is the multicast address used by default by the two services above. @end defvar +@node Mail Home Services +@subsection Mail Home Services + +@cindex msmtp +@uref{https://marlam.de/msmtp, MSMTP} is an SMTP client. + +@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{logfile} (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{passwordeval} (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 @subsection Messaging Home Services diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm new file mode 100644 index 0000000000..e151cf8607 --- /dev/null +++ b/gnu/home/services/mail.scm @@ -0,0 +1,219 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2023 Tanguy Le Carrour +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services mail) + #:use-module (guix gexp) + #:use-module (gnu packages) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu home services) + #:use-module (gnu home services shepherd) + #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (home-msmtp-configuration + home-msmtp-configuration? + home-msmtp-configuration-defaults + home-msmtp-configuration-accounts + home-msmtp-configuration-default-account + home-msmtp-configuration-extra-content + home-msmtp-service-type + msmtp-configuration + msmtp-configuration-auth? + msmtp-configuration-tls? + msmtp-configuration-tls-starttls? + msmtp-configuration-tls-trust-file + msmtp-configuration-logfile + msmtp-configuration-host + msmtp-configuration-port + msmtp-configuration-user + msmtp-configuration-from + msmtp-configuration-passwordeval + msmtp-configuration-extra-content + msmtp-account + msmtp-account-name + msmtp-account-configuration)) + +(define-maybe string) +(define-maybe boolean) +(define-maybe integer) + +;; Serialization of 'msmtp'. +(define (uglify-symbol field-name) + (let* ((name (symbol->string field-name)) + (ugly-name (string-replace-substring name "-" "_"))) + (if (string-suffix? "?" ugly-name) + (string-drop-right ugly-name 1) + ugly-name))) + +(define (msmtp-configuration-serialize-maybe-boolean field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (if #$value "on" "off") "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-string field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " #$value "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-integer field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (number->string #$value) "\n") + "")) + +(define (msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +(define (msmtp-account-serialize-name field-name value) + #~(string-append "\naccount " #$value "\n")) + +(define (msmtp-account-serialize-msmtp-configuration field-name value) + #~(string-append #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-msmtp-configuration-serialize-list-of-msmtp-accounts field-name value) + #~(string-append #$@(map (cut serialize-configuration <> msmtp-account-fields) + value))) + +(define (home-msmtp-configuration-serialize-msmtp-configuration field-name value) + #~(string-append "defaults\n" + #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-msmtp-configuration-serialize-default-account field-name value) + #~(if #$(maybe-value-set? value) + (string-append "\naccount default : " #$value "\n") + "")) + +(define (home-msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +;; Configuration of 'msmtp'. +;; Source . +(define-configuration msmtp-configuration + (auth? + maybe-boolean + "Enable or disable authentication.") + + (tls? + maybe-boolean + "Enable or disable TLS (also known as SSL) for secured connections.") + + (tls-starttls? + maybe-boolean + "Choose the TLS variant: start TLS from within the session (‘on’, default), +or tunnel the session through TLS (‘off’).") + + (tls-trust-file + maybe-string + "Activate server certificate verification using a list of +trusted Certification Authorities (CAs).") + + (logfile + maybe-string + "Enable logging to the specified file. An empty argument disables logging. +The file name ‘-’ directs the log information to standard output.") + + (host + maybe-string + "The SMTP server to send the mail to.") + + (port + 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\").") + + (user + maybe-string + "Set the user name for authentication.") + + (from + maybe-string + "Set the envelope-from address.") + + (passwordeval + maybe-string + "Set the password for authentication to the output (stdout) of the command cmd.") + + (extra-content + (string "") + "Extra content appended as-is to the configuration block. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer msmtp-configuration-serialize-extra-content)) + + (prefix msmtp-configuration-)) + +(define-configuration msmtp-account + (name + (string) + "The unique name of the account." + (serializer msmtp-account-serialize-name)) + + (configuration + (msmtp-configuration) + "The configuration for this given account.") + + (prefix msmtp-account-)) + +(define (list-of-msmtp-accounts? lst) + (every msmtp-account? lst)) + +(define-configuration home-msmtp-configuration + (defaults + (msmtp-configuration (msmtp-configuration)) + "The configuration that will be set as default for all accounts.") + + (accounts + (list-of-msmtp-accounts '()) + "A list of @code{msmtp-account} records which contain +information about all your accounts.") + + (default-account + maybe-string + "Set the default account." + (serializer home-msmtp-configuration-serialize-default-account)) + + (extra-content + (string "") + "Extra content appended as-is to the configuration file. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer home-msmtp-configuration-serialize-extra-content)) + + (prefix home-msmtp-configuration-)) + +(define (home-msmtp-files-service config) + (list + `(".config/msmtp/config" + ,(mixed-text-file "config" + (serialize-configuration config home-msmtp-configuration-fields))))) + +(define (home-msmtp-profile-service config) + (specifications->packages (list "msmtp"))) + +(define home-msmtp-service-type + (service-type (name 'home-msmtp) + (extensions + (list + (service-extension + home-profile-service-type + home-msmtp-profile-service) + (service-extension + home-files-service-type + home-msmtp-files-service))) + (default-value (home-msmtp-configuration)) + (description "Configures msmtp."))) diff --git a/gnu/local.mk b/gnu/local.mk index 01ffe3fdb6..3f57ca3c98 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -93,6 +93,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/fontutils.scm \ %D%/home/services/gnupg.scm \ %D%/home/services/guix.scm \ + %D%/home/services/mail.scm \ %D%/home/services/media.scm \ %D%/home/services/messaging.scm \ %D%/home/services/pm.scm \ -- 2.39.2 From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 30 17:30:22 2023 Received: (at 62969) by debbugs.gnu.org; 30 Apr 2023 21:30:22 +0000 Received: from localhost ([127.0.0.1]:38525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptEcg-0007Tq-DO for submit@debbugs.gnu.org; Sun, 30 Apr 2023 17:30:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptEcd-0007Ta-ST for 62969@debbugs.gnu.org; Sun, 30 Apr 2023 17:30:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptEcW-00054B-SA; Sun, 30 Apr 2023 17:30:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=bUWsFqc0AIBjtgPxgEB/60G2LOgl7z2tYhqkOy6f+Mk=; b=Iy/PYQir7nfnbbI6T/Wn Veleg6dPdOEDVu1wvcCRavhmlPBSuCCGJFDvgUYfgCe88FO1pGMhN0ofB2XynvehENwzZ/K8WpqKh lK8d3NSo0iYrDyhg32PCkMXlQufT6AWt1HQ/HKNGtngoGyNstKVRcMzW9M5V74hMA9ZBr41v2hIjP iTrhNE6nNA+ql05MTuRR0lOPp3gxEhrrYZnKUpvyC8ejoy2gmB4L5EiGgJbmt1EFF/WAe7t3q84iS qFjT/VoOj0CFpE0MehX+YnqDPSV9yb8FuG9dwCOm/4jLOy4O1mgNWCSc6Jr8BmnIYiNgtoSiYE9F7 RovL+ZBUlNVqFg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptEcW-0002se-5a; Sun, 30 Apr 2023 17:30:12 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Tanguy Le Carrour Subject: Re: bug#62969: [PATCH] home: Add msmtp service. References: <20230420144230.9392-1-tanguy@bioneland.org> <20230423171217.14894-1-tanguy@bioneland.org> Date: Sun, 30 Apr 2023 23:30:10 +0200 In-Reply-To: <20230423171217.14894-1-tanguy@bioneland.org> (Tanguy Le Carrour's message of "Sun, 23 Apr 2023 19:12:17 +0200") Message-ID: <87ilddnjml.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Tanguy! :-) Tanguy Le Carrour skribis: > * gnu/home/services/mail.scm: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > * doc/guix.texi (Mailing): New node. I get: --8<---------------cut here---------------start------------->8--- [ 94%] GUILEC gnu/home/services/mail.go gnu/home/services/mail.scm:52:0: warning: possibly unbound variable `serial= ize-string' gnu/home/services/mail.scm:53:0: warning: possibly unbound variable `serial= ize-boolean' gnu/home/services/mail.scm:54:0: warning: possibly unbound variable `serial= ize-integer' --8<---------------cut here---------------end--------------->8--- I guess these procedures should be provided as well? > +@node Mail Home Services > +@subsection Mail Home Services > + > +@cindex msmtp > +@uref{https://marlam.de/msmtp, MSMTP} is an SMTP client. Could you give a bit more context, including @acronym for SMTP? It would also be nice to provide one commented example that readers might copy/paste as a starting point. You can take inspiration form the =E2=80=9CMcron Home Services=E2=80=9D, = =E2=80=9CSecure Shell=E2=80=9D, or =E2=80=9CMessaging Home Services=E2=80=9D nodes, for example. [...] > + (default-value (home-msmtp-configuration)) > + (description "Configures msmtp."))) Likewise, something like =E2=80=9CConfigure msmtp, a simple @acronym{SMTP, = =E2=80=A6} client that can relay email to SMTP servers.=E2=80=9D Otherwise this looks great to me, thank you! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 06:02:01 2023 Received: (at 62969) by debbugs.gnu.org; 3 May 2023 10:02:02 +0000 Received: from localhost ([127.0.0.1]:45585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pu9JA-0003L4-QX for submit@debbugs.gnu.org; Wed, 03 May 2023 06:02:01 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:47857) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pu9J6-0003Ki-79 for 62969@debbugs.gnu.org; Wed, 03 May 2023 06:01:59 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id 9317B240008; Wed, 3 May 2023 10:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1683108110; 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=RAThyZkfIauxIbSzLy4zSgq08ZZzY4zLyhVVcFk1Q6Q=; b=YMaQiIT5gdFUZi94xu0InPZg2ay0qz1LgYCQdswnDumjwxJla6MDdIXTcT+SkGvhwrRKAn fmBbatgHKo6u0ccyurnApXFsFtnIfVOo0egeQ32AmrSg0K++acrn1NQCnl5TycvWSYLv6z cDMLPPkxaII0ltnQOoAshApwFLKHlo44amkZ00mVDMBGC0h1FVQ1MMTthc4Nu02IqRpATR 4ljczMFA+RVL1bMg5b0yiKZkWsWBSVEU5tTGgICnehFoZlUrVnlI65GI8n2flH3BoSFcoD 05937yxK3euWlD9CfY2UCo68B6x/241ppjIGzq1ncgRTOwCEkOqtuLTpXa5QMQ== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable References: <20230420144230.9392-1-tanguy@bioneland.org> <20230423171217.14894-1-tanguy@bioneland.org> <87ilddnjml.fsf_-_@gnu.org> Subject: [PATCH v3] home: Add msmtp service. From: Tanguy LE CARROUR To: Ludovic =?utf-8?q?Court=C3=A8s?= In-Reply-To: <87ilddnjml.fsf_-_@gnu.org> Date: Wed, 03 May 2023 12:01:48 +0200 Message-ID: <168310810854.1650.852938763274164245@localhost> User-Agent: alot/0.10 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Ludo=E2=80=99, Quoting Ludovic Court=C3=A8s (2023-04-30 23:30:10) > Tanguy Le Carrour skribis: >=20 > > * gnu/home/services/mail.scm: New file. > > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > > * doc/guix.texi (Mailing): New node. >=20 > I get: >=20 > --8<---------------cut here---------------start------------->8--- > [ 94%] GUILEC gnu/home/services/mail.go > gnu/home/services/mail.scm:52:0: warning: possibly unbound variable `seri= alize-string' > gnu/home/services/mail.scm:53:0: warning: possibly unbound variable `seri= alize-boolean' > gnu/home/services/mail.scm:54:0: warning: possibly unbound variable `seri= alize-integer' > --8<---------------cut here---------------end--------------->8--- > > I guess these procedures should be provided as well? I also get them when making `gnu/home/services/mail.go`. But aren't those "just" warnings. Everything seems to work as expected and when I `guix home container test.home.scm` I get the expected `.config/msmtp/config` file. > > +@node Mail Home Services > > +@subsection Mail Home Services > > + > > +@cindex msmtp > > +@uref{https://marlam.de/msmtp, MSMTP} is an SMTP client. >=20 > Could you give a bit more context, including @acronym for SMTP? It > would also be nice to provide one commented example that readers might > copy/paste as a starting point. >=20 > You can take inspiration form the =E2=80=9CMcron Home Services=E2=80=9D, = =E2=80=9CSecure Shell=E2=80=9D, > or =E2=80=9CMessaging Home Services=E2=80=9D nodes, for example. >=20 > [...] >=20 > > + (default-value (home-msmtp-configuration)) > > + (description "Configures msmtp."))) >=20 > Likewise, something like =E2=80=9CConfigure msmtp, a simple @acronym{SMTP= , =E2=80=A6} > client that can relay email to SMTP servers.=E2=80=9D I tried to improve it based on your suggestions. No yet perfect, though. Cheers, Tanguy * gnu/home/services/mail.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Mailing): New node. --- doc/guix.texi | 137 +++++++++++++++++++++++ gnu/home/services/mail.scm | 221 +++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 3 files changed, 359 insertions(+) create mode 100644 gnu/home/services/mail.scm diff --git a/doc/guix.texi b/doc/guix.texi index 7af2a85499..2ae815475b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -114,6 +114,7 @@ Copyright @copyright{} 2023 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby +Copyright @copyright{} 2023 Tanguy Le Carrour Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -41887,6 +41888,7 @@ Home Services * Guix: Guix Home Services. Services for Guix. * Fonts: Fonts Home Services. Services for managing User's fonts. * Sound: Sound Home Services. Dealing with audio. +* Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. @end menu @@ -43110,6 +43112,141 @@ Sound Home Services This is the multicast address used by default by the two services above. @end defvar +@node Mail Home Services +@subsection Mail Home Services + +The @code{(gnu home services mail)} modules provides services that help +you set up the tools to work with emails in your home environment. + +@cindex msmtp +@uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail +Transfer Protocol} client. It sends mails 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 +@code{~/.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 + (accounts + (list + (msmtp-account + (name "alice") + (configuration + (msmtp-configuration + (host "mail.example.org") + (port 587) + (user "alice") + (passwordeval "pass Mail/alice")))))))) +@end lisp +@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 (=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{logfile} (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 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{passwordeval} (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 @subsection Messaging Home Services diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm new file mode 100644 index 0000000000..ec5f869c87 --- /dev/null +++ b/gnu/home/services/mail.scm @@ -0,0 +1,221 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2023 Tanguy Le Carrour +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services mail) + #:use-module (guix gexp) + #:use-module (gnu packages) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu home services) + #:use-module (gnu home services shepherd) + #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (home-msmtp-configuration + home-msmtp-configuration? + home-msmtp-configuration-defaults + home-msmtp-configuration-accounts + home-msmtp-configuration-default-account + home-msmtp-configuration-extra-content + home-msmtp-service-type + msmtp-configuration + msmtp-configuration-auth? + msmtp-configuration-tls? + msmtp-configuration-tls-starttls? + msmtp-configuration-tls-trust-file + msmtp-configuration-logfile + msmtp-configuration-host + msmtp-configuration-port + msmtp-configuration-user + msmtp-configuration-from + msmtp-configuration-passwordeval + msmtp-configuration-extra-content + msmtp-account + msmtp-account-name + msmtp-account-configuration)) + +(define-maybe string) +(define-maybe boolean) +(define-maybe integer) + +;; Serialization of 'msmtp'. +(define (uglify-symbol field-name) + (let* ((name (symbol->string field-name)) + (ugly-name (string-replace-substring name "-" "_"))) + (if (string-suffix? "?" ugly-name) + (string-drop-right ugly-name 1) + ugly-name))) + +(define (msmtp-configuration-serialize-maybe-boolean field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (if #$value "on" "of= f") "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-string field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " #$value "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-integer field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (number->string #$va= lue) "\n") + "")) + +(define (msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=3D? #$value "") "" (string-append #$value "\n"))) + +(define (msmtp-account-serialize-name field-name value) + #~(string-append "\naccount " #$value "\n")) + +(define (msmtp-account-serialize-msmtp-configuration field-name value) + #~(string-append #$(serialize-configuration value msmtp-configuration-fi= elds))) + +(define (home-msmtp-configuration-serialize-list-of-msmtp-accounts field-n= ame value) + #~(string-append #$@(map (cut serialize-configuration <> msmtp-account-f= ields) + value))) + +(define (home-msmtp-configuration-serialize-msmtp-configuration field-name= value) + #~(string-append "defaults\n" + #$(serialize-configuration value msmtp-configuration-fi= elds))) + +(define (home-msmtp-configuration-serialize-default-account field-name val= ue) + #~(if #$(maybe-value-set? value) + (string-append "\naccount default : " #$value "\n") + "")) + +(define (home-msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=3D? #$value "") "" (string-append #$value "\n"))) + +;; Configuration of 'msmtp'. +;; Source . +(define-configuration msmtp-configuration + (auth? + maybe-boolean + "Enable or disable authentication.") + + (tls? + maybe-boolean + "Enable or disable TLS (also known as SSL) for secured connections.") + + (tls-starttls? + 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).") + + (tls-trust-file + maybe-string + "Activate server certificate verification using a list of +trusted Certification Authorities (CAs).") + + (logfile + maybe-string + "Enable logging to the specified file. An empty argument disables loggi= ng. +The file name =E2=80=98-=E2=80=99 directs the log information to standard = output.") + + (host + maybe-string + "The SMTP server to send the mail to.") + + (port + 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\").") + + (user + maybe-string + "Set the user name for authentication.") + + (from + maybe-string + "Set the envelope-from address.") + + (passwordeval + maybe-string + "Set the password for authentication to the output (stdout) of the com= mand cmd.") + + (extra-content + (string "") + "Extra content appended as-is to the configuration block. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer msmtp-configuration-serialize-extra-content)) + + (prefix msmtp-configuration-)) + +(define-configuration msmtp-account + (name + (string) + "The unique name of the account." + (serializer msmtp-account-serialize-name)) + + (configuration + (msmtp-configuration) + "The configuration for this given account.") + + (prefix msmtp-account-)) + +(define (list-of-msmtp-accounts? lst) + (every msmtp-account? lst)) + +(define-configuration home-msmtp-configuration + (defaults + (msmtp-configuration (msmtp-configuration)) + "The configuration that will be set as default for all accounts.") + + (accounts + (list-of-msmtp-accounts '()) + "A list of @code{msmtp-account} records which contain +information about all your accounts.") + + (default-account + maybe-string + "Set the default account." + (serializer home-msmtp-configuration-serialize-default-account)) + + (extra-content + (string "") + "Extra content appended as-is to the configuration file. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer home-msmtp-configuration-serialize-extra-content)) + + (prefix home-msmtp-configuration-)) + +(define (home-msmtp-files-service config) + (list + `(".config/msmtp/config" + ,(mixed-text-file "config" + (serialize-configuration config home-msmtp-configur= ation-fields))))) + +(define (home-msmtp-profile-service config) + (specifications->packages (list "msmtp"))) + +(define home-msmtp-service-type + (service-type (name 'home-msmtp) + (extensions + (list + (service-extension + home-profile-service-type + home-msmtp-profile-service) + (service-extension + home-files-service-type + home-msmtp-files-service))) + (default-value (home-msmtp-configuration)) + (description "Configure msmtp, a simple +@acronym{SMTP, Simple Mail Transfer Protocol} client that can relay email +to SMTP servers."))) diff --git a/gnu/local.mk b/gnu/local.mk index 4305bee89c..94ea3a4e8d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -93,6 +93,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/home/services/fontutils.scm \ %D%/home/services/gnupg.scm \ %D%/home/services/guix.scm \ + %D%/home/services/mail.scm \ %D%/home/services/media.scm \ %D%/home/services/messaging.scm \ %D%/home/services/pm.scm \ base-commit: 94e2e3553440a2a5ac4a312e80b8ea21ddebafeb --=20 2.39.2 From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 16:27:16 2023 Received: (at 62969) by debbugs.gnu.org; 3 May 2023 20:27:16 +0000 Received: from localhost ([127.0.0.1]:47833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puJ4F-0002OV-Jz for submit@debbugs.gnu.org; Wed, 03 May 2023 16:27:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35032) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puJ4C-0002OF-Bv for 62969@debbugs.gnu.org; Wed, 03 May 2023 16:27:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puJ46-00079d-H0; Wed, 03 May 2023 16:27:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=D9PUW3tER+OmvO+QIjBkHjhwh7YnSMFJ8/XLGCQ0LtM=; b=NPCu2yHkP4HB4yydXVS2 gL4StSYsuPTfpDqS2DvO7fHI2MoPHVDX8zxMNix4ife1mWYNJdAWEn+EJ1ANhVsXYePkhD3+PjhzT +/rrp/4KZ0GVaY2vfbRiaCT6YZPmma4+Q1uCNrdotQJVXxJ546JGNcRsd2DOsds5Q7v+5MP+iORZA M/L26F0qNh++eL/Fyj+aISmaVtaKmGjJcU+uoYP5wL92AHZiNo/z/5PsSEq8O6Tq5SuwYkVS0AbB4 qPkgjAUodoz/8JN2O7VUM5l2RoPqvcjSV7YKnsefAoic3fOEVlKl/IBavTIs3TGToI0Z6cRnXgqQf bWgrZY6cTdLnXw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puJ46-00045W-2v; Wed, 03 May 2023 16:27:06 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Tanguy LE CARROUR Subject: Re: [PATCH v3] home: Add msmtp service. References: <20230420144230.9392-1-tanguy@bioneland.org> <20230423171217.14894-1-tanguy@bioneland.org> <87ilddnjml.fsf_-_@gnu.org> <168310810854.1650.852938763274164245@localhost> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quartidi 14 =?utf-8?Q?Flor=C3=A9al?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du =?utf-8?Q?Cham=C3=A9risier?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 03 May 2023 22:27:03 +0200 In-Reply-To: <168310810854.1650.852938763274164245@localhost> (Tanguy LE CARROUR's message of "Wed, 03 May 2023 12:01:48 +0200") Message-ID: <87ednxyxd4.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Hello! Tanguy LE CARROUR skribis: > Quoting Ludovic Court=C3=A8s (2023-04-30 23:30:10) >> Tanguy Le Carrour skribis: >>=20 >> > * gnu/home/services/mail.scm: New file. >> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. >> > * doc/guix.texi (Mailing): New node. >>=20 >> I get: >>=20 >> --8<---------------cut here---------------start------------->8--- >> [ 94%] GUILEC gnu/home/services/mail.go >> gnu/home/services/mail.scm:52:0: warning: possibly unbound variable `ser= ialize-string' >> gnu/home/services/mail.scm:53:0: warning: possibly unbound variable `ser= ialize-boolean' >> gnu/home/services/mail.scm:54:0: warning: possibly unbound variable `ser= ialize-integer' >> --8<---------------cut here---------------end--------------->8--- >> >> I guess these procedures should be provided as well? > > I also get them when making `gnu/home/services/mail.go`. But aren't > those "just" warnings. It means that there=E2=80=99s code referring to these procedures, and that = they don=E2=80=99t exist. It=E2=80=99s worth investigating anyway. > Everything seems to work as expected and when I `guix home container > test.home.scm` I get the expected `.config/msmtp/config` file. Perhaps that doesn=E2=80=99t exercise those bits, maybe because you=E2=80= =99re not using string-valued or boolean-valued fields or something? A couple of minor things: > * gnu/home/services/mail.scm: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > * doc/guix.texi (Mailing): New node. > +@subsection Mail Home Services > + > +The @code{(gnu home services mail)} modules provides services that help =E2=80=9Cmodule=E2=80=9D (singular) > +@uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail > +Transfer Protocol} client. It sends mails to a predefined SMTP server =E2=80=9Cmail=E2=80=9D (singular) > +@code{~/.config/msmtp/config} file. =E2=80=9C@file=E2=80=9D This new intro + example look nice to me! > +@item @code{logfile} (type: maybe-string) [...] > +@item @code{passwordeval} (type: maybe-string) > +Set the password for authentication to the output (stdout) of the > +command cmd. Sorry for not noticing earlier but I=E2=80=99d suggest =E2=80=98log-file=E2= =80=99 and =E2=80=98password-evaluation=E2=80=99 (?) to stick with the established nam= ing convention. So I think beyond this the main issue is figuring out the missing serialization procedures, and then we=E2=80=99re done! Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed May 17 04:52:14 2023 Received: (at 62969) by debbugs.gnu.org; 17 May 2023 08:52:14 +0000 Received: from localhost ([127.0.0.1]:48883 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzCtK-0003uv-GA for submit@debbugs.gnu.org; Wed, 17 May 2023 04:52:14 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:41275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzCtI-0003ug-HH for 62969@debbugs.gnu.org; Wed, 17 May 2023 04:52:13 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id EA6C5240009; Wed, 17 May 2023 08:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1684313526; 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=bD8E14P15rIFumqk4wEQWRznne7SQJ7p+8wkdyW6auA=; b=Z37F+pOHWBzsJXzPBB/m3xmB2piMoAUcK2bHrBDFakBovKo7/fNGVDUTkOOMwmvWSmvppy EiG91YiPYCeZWoQEKsWttYPQ5HaLZsZ1eVOOVlfEc7NpfqFQ+b6/uBtDhnI8BpU39LazO4 wXwTbk1HDw34gEbSG/XDkPI8dWjK0o03GZI2MY8q2DfaqAPw4GW9xkTzCvcxBD3FUEmN0a /LEOJzvzQ0Zn83oLV9+Tf2w8sCm8XYhRIzTwqRDlfbLdEUoZMw+5wpkqoD8VQXub6otUk2 m4zLVFwGGUW1jSN/HZtaUNe35nZj+JZKrNgjooc+B9P4DXozOWMNPOKTM8027g== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable References: <20230420144230.9392-1-tanguy@bioneland.org> <20230423171217.14894-1-tanguy@bioneland.org> <87ilddnjml.fsf_-_@gnu.org> <168310810854.1650.852938763274164245@localhost> <87ednxyxd4.fsf@gnu.org> Subject: Re: [PATCH v3] home: Add msmtp service. From: Tanguy LE CARROUR To: Ludovic =?utf-8?q?Court=C3=A8s?= In-Reply-To: <87ednxyxd4.fsf@gnu.org> Date: Wed, 17 May 2023 10:52:05 +0200 Message-ID: <168431352507.9673.2828328652177284378@localhost> User-Agent: alot/0.10 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62969 Cc: 62969@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi, Quoting Ludovic Court=C3=A8s (2023-05-03 22:27:03) > Tanguy LE CARROUR skribis: >=20 > > Quoting Ludovic Court=C3=A8s (2023-04-30 23:30:10) > >> Tanguy Le Carrour skribis: > >>=20 > >> > * gnu/home/services/mail.scm: New file. > >> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > >> > * doc/guix.texi (Mailing): New node. > >>=20 > >> I get: > >>=20 > >> --8<---------------cut here---------------start------------->8--- > >> [ 94%] GUILEC gnu/home/services/mail.go > >> gnu/home/services/mail.scm:52:0: warning: possibly unbound variable `s= erialize-string' > >> gnu/home/services/mail.scm:53:0: warning: possibly unbound variable `s= erialize-boolean' > >> gnu/home/services/mail.scm:54:0: warning: possibly unbound variable `s= erialize-integer' > >> --8<---------------cut here---------------end--------------->8--- > >> > >> I guess these procedures should be provided as well? > > > > I also get them when making `gnu/home/services/mail.go`. But aren't > > those "just" warnings. >=20 > It means that there=E2=80=99s code referring to these procedures, and tha= t they > don=E2=80=99t exist. It=E2=80=99s worth investigating anyway. I have noooo clue where to start! #noob=E2=80=99 =F0=9F=98=85 > A couple of minor things: > [=E2=80=A6] > > +The @code{(gnu home services mail)} modules provides services that help >=20 > =E2=80=9Cmodule=E2=80=9D (singular) Done! > > +@uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail > > +Transfer Protocol} client. It sends mails to a predefined SMTP server >=20 > =E2=80=9Cmail=E2=80=9D (singular) Done! > > +@code{~/.config/msmtp/config} file. >=20 > =E2=80=9C@file=E2=80=9D Done! > This new intro + example look nice to me! >=20 > > +@item @code{logfile} (type: maybe-string) >=20 > [...] >=20 > > +@item @code{passwordeval} (type: maybe-string) > > +Set the password for authentication to the output (stdout) of the > > +command cmd. >=20 > Sorry for not noticing earlier but I=E2=80=99d suggest =E2=80=98log-file= =E2=80=99 and > =E2=80=98password-evaluation=E2=80=99 (?) to stick with the established n= aming > convention. Done! > So I think beyond this the main issue is figuring out the missing > serialization procedures, and then we=E2=80=99re done! I'm sending a v4! Cheers, --=20 Tanguy From debbugs-submit-bounces@debbugs.gnu.org Wed May 17 04:52:48 2023 Received: (at 62969) by debbugs.gnu.org; 17 May 2023 08:52:49 +0000 Received: from localhost ([127.0.0.1]:48888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzCtr-0003vv-U0 for submit@debbugs.gnu.org; Wed, 17 May 2023 04:52:48 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:53813) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzCtp-0003vg-Up for 62969@debbugs.gnu.org; Wed, 17 May 2023 04:52:47 -0400 Received: (Authenticated sender: tanguy@bioneland.org) by mail.gandi.net (Postfix) with ESMTPSA id 9219AFF806; Wed, 17 May 2023 08:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1684313560; 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=tm+m1aRUn/4aqovB4Xstap7zsFMQ9HGP8Yz0FeMbHCc=; b=A9H+sRSMCEtGWMNr3CleelMD0EfB2LLlNLVRtbvgPKKKl5JW4pxDuk04KTupqseqhgTSrf 0C5X8/cHqforrxFNUw6ShQYXmdjqN7CjoDV3hejTFjSZnTLSnQWC/Hutq5LuXAGJ7zRHWk 7hOjzrSkp2EzncTtMicnKuE1PleW0VyM25+9xkwGcJXea9+LSz4ae2nBxYup4EaYtT1sS2 uRfGPvhikiaNt2aijNxrtaiz26kL35VKJIGOAqULA3PCPmIysEdomClEIbiyHL2OD5lIpG eiE193eIuNksD/Eo/XDUb+K+wKxF4lK3Xulyh5kkWynvrbZzlCuwPnDgI/CqVw== From: Tanguy Le Carrour To: 62969@debbugs.gnu.org Subject: [PATCH v4] home: Add msmtp service. Date: Wed, 17 May 2023 10:51:44 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Debbugs-Cc: ( X-Debbugs-Cc: Andrew Tropin X-Debbugs-Cc: Ludovic Courtès Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62969 Cc: ludo@gnu.org, mirai@makinata.eu, Tanguy Le Carrour X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * gnu/home/services/mail.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Mailing): New node. --- doc/guix.texi | 137 ++++++++++++++++++++++ gnu/home/services/mail.scm | 229 +++++++++++++++++++++++++++++++++++++ gnu/local.mk | 3 +- 3 files changed, 368 insertions(+), 1 deletion(-) create mode 100644 gnu/home/services/mail.scm diff --git a/doc/guix.texi b/doc/guix.texi index 60972f408d..e61d7f81ed 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -115,6 +115,7 @@ Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby Copyright @copyright{} 2023 Nathaniel Nicandro +Copyright @copyright{} 2023 Tanguy Le Carrour Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -42223,6 +42224,7 @@ Home Services * Guix: Guix Home Services. Services for Guix. * Fonts: Fonts Home Services. Services for managing User's fonts. * Sound: Sound Home Services. Dealing with audio. +* Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. @end menu @@ -43452,6 +43454,141 @@ Sound Home Services This is the multicast address used by default by the two services above. @end defvar +@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 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 + (accounts + (list + (msmtp-account + (name "alice") + (configuration + (msmtp-configuration + (host "mail.example.org") + (port 587) + (user "alice") + (password-eval "pass Mail/alice")))))))) +@end lisp +@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 @subsection Messaging Home Services diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm new file mode 100644 index 0000000000..c3d34240f1 --- /dev/null +++ b/gnu/home/services/mail.scm @@ -0,0 +1,229 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2023 Tanguy Le Carrour +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services mail) + #:use-module (guix gexp) + #:use-module (gnu packages) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu home services) + #:use-module (gnu home services shepherd) + #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (home-msmtp-configuration + home-msmtp-configuration? + home-msmtp-configuration-defaults + home-msmtp-configuration-accounts + home-msmtp-configuration-default-account + home-msmtp-configuration-extra-content + home-msmtp-service-type + msmtp-configuration + msmtp-configuration-auth? + msmtp-configuration-tls? + msmtp-configuration-tls-starttls? + msmtp-configuration-tls-trust-file + msmtp-configuration-log-file + msmtp-configuration-host + msmtp-configuration-port + msmtp-configuration-user + msmtp-configuration-from + msmtp-configuration-password-eval + msmtp-configuration-extra-content + msmtp-account + msmtp-account-name + msmtp-account-configuration)) + +(define-maybe string) +(define-maybe boolean) +(define-maybe integer) + +;; Serialization of 'msmtp'. +(define (uglify-symbol field-name) + (let* ((name (symbol->string field-name)) + (ugly-name (string-replace-substring name "-" "_"))) + (if (string-suffix? "?" ugly-name) + (string-drop-right ugly-name 1) + ugly-name))) + +(define (msmtp-configuration-serialize-maybe-boolean field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (if #$value "on" "off") "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-string field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " #$value "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-string-no-underscore field-name value) + #~(if #$(maybe-value-set? value) + (string-append + #$(string-replace-substring (uglify-symbol field-name) "_" "") " " #$value "\n") + "")) + +(define (msmtp-configuration-serialize-maybe-integer field-name value) + #~(if #$(maybe-value-set? value) + (string-append #$(uglify-symbol field-name) " " (number->string #$value) "\n") + "")) + +(define (msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +(define (msmtp-account-serialize-name field-name value) + #~(string-append "\naccount " #$value "\n")) + +(define (msmtp-account-serialize-msmtp-configuration field-name value) + #~(string-append #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-msmtp-configuration-serialize-list-of-msmtp-accounts field-name value) + #~(string-append #$@(map (cut serialize-configuration <> msmtp-account-fields) + value))) + +(define (home-msmtp-configuration-serialize-msmtp-configuration field-name value) + #~(string-append "defaults\n" + #$(serialize-configuration value msmtp-configuration-fields))) + +(define (home-msmtp-configuration-serialize-default-account field-name value) + #~(if #$(maybe-value-set? value) + (string-append "\naccount default : " #$value "\n") + "")) + +(define (home-msmtp-configuration-serialize-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +;; Configuration of 'msmtp'. +;; Source . +(define-configuration msmtp-configuration + (auth? + maybe-boolean + "Enable or disable authentication.") + + (tls? + maybe-boolean + "Enable or disable TLS (also known as SSL) for secured connections.") + + (tls-starttls? + maybe-boolean + "Choose the TLS variant: start TLS from within the session (‘on’, default), +or tunnel the session through TLS (‘off’).") + + (tls-trust-file + maybe-string + "Activate server certificate verification using a list of +trusted Certification Authorities (CAs).") + + (log-file + maybe-string + "Enable logging to the specified file. An empty argument disables logging. +The file name ‘-’ directs the log information to standard output." + (serializer msmtp-configuration-serialize-maybe-string-no-underscore)) + + (host + maybe-string + "The SMTP server to send the mail to.") + + (port + 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\").") + + (user + maybe-string + "Set the user name for authentication.") + + (from + maybe-string + "Set the envelope-from address.") + + (password-eval + maybe-string + "Set the password for authentication to the output (stdout) of the command cmd." + (serializer msmtp-configuration-serialize-maybe-string-no-underscore)) + + (extra-content + (string "") + "Extra content appended as-is to the configuration block. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer msmtp-configuration-serialize-extra-content)) + + (prefix msmtp-configuration-)) + +(define-configuration msmtp-account + (name + (string) + "The unique name of the account." + (serializer msmtp-account-serialize-name)) + + (configuration + (msmtp-configuration) + "The configuration for this given account.") + + (prefix msmtp-account-)) + +(define (list-of-msmtp-accounts? lst) + (every msmtp-account? lst)) + +(define-configuration home-msmtp-configuration + (defaults + (msmtp-configuration (msmtp-configuration)) + "The configuration that will be set as default for all accounts.") + + (accounts + (list-of-msmtp-accounts '()) + "A list of @code{msmtp-account} records which contain +information about all your accounts.") + + (default-account + maybe-string + "Set the default account." + (serializer home-msmtp-configuration-serialize-default-account)) + + (extra-content + (string "") + "Extra content appended as-is to the configuration file. Run +@command{man msmtp} for more information about the configuration file +format." + (serializer home-msmtp-configuration-serialize-extra-content)) + + (prefix home-msmtp-configuration-)) + +(define (home-msmtp-files-service config) + (list + `(".config/msmtp/config" + ,(mixed-text-file "config" + (serialize-configuration config home-msmtp-configuration-fields))))) + +(define (home-msmtp-profile-service config) + (specifications->packages (list "msmtp"))) + +(define home-msmtp-service-type + (service-type (name 'home-msmtp) + (extensions + (list + (service-extension + home-profile-service-type + home-msmtp-profile-service) + (service-extension + home-files-service-type + home-msmtp-files-service))) + (default-value (home-msmtp-configuration)) + (description "Configure msmtp, a simple +@acronym{SMTP, Simple Mail Transfer Protocol} client that can relay email +to SMTP servers."))) diff --git a/gnu/local.mk b/gnu/local.mk index 42514ded8e..930e69e289 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -35,7 +35,7 @@ # Copyright © 2020 Ryan Prior # Copyright © 2020 Jan Wielkiewicz # Copyright © 2020, 2021 Brice Waegeneire -# Copyright © 2020 Tanguy Le Carrour +# Copyright © 2020, 2023 Tanguy Le Carrour # Copyright © 2020 Martin Becze # Copyright © 2020 Malte Frank Gerdes # Copyright © 2020, 2023 Vinicius Monego @@ -94,6 +94,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/fontutils.scm \ %D%/home/services/gnupg.scm \ %D%/home/services/guix.scm \ + %D%/home/services/mail.scm \ %D%/home/services/media.scm \ %D%/home/services/messaging.scm \ %D%/home/services/pm.scm \ base-commit: c8e599b9391f789a8a3e2183fc8f0c2a5061ceb0 -- 2.40.1 From debbugs-submit-bounces@debbugs.gnu.org Mon May 29 17:43:48 2023 Received: (at 62969-done) by debbugs.gnu.org; 29 May 2023 21:43:48 +0000 Received: from localhost ([127.0.0.1]:59352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3kea-0001Dj-Ex for submit@debbugs.gnu.org; Mon, 29 May 2023 17:43:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3keY-0001DQ-4r for 62969-done@debbugs.gnu.org; Mon, 29 May 2023 17:43:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3keS-0001FP-1m; Mon, 29 May 2023 17:43:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=qS/lDLLhyJxNiTbtIYay+RvQgs8IX6Zk6BDpdqWOWwU=; b=NJkMjjiuHv0aqZTcDwG2 zj1r8qwHxSp53gp8d9KJedR0FMwLO/VF6Ky/PQuhd99wIjLRvyBSMK1z6nG086pQly036yDBx3smn E4Vqxk2BAtfZkpGiyChGWNl4lhVQYgGhug9etTsx3orDpKmjnzZZP7husKTHK58lBMLTHnCdANN7L Z7hYTz24fGSGOf2y/OLBDHO1rQwhWEFwmD5w+xCpdftdlUp8h94KsQpHJtkCkRnZVjhbd2vK5C1YQ lOR2AJitPbWYnRgayjUsxNSYmp2CIOQqgk7TMJzkMTFbItVk0SSLpe1YYX1rWzajqflbF3EgUtBVm Lt0qw884cr/wmg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3ke5-0004Tf-N7; Mon, 29 May 2023 17:43:22 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Tanguy Le Carrour Subject: Re: bug#62969: [PATCH] home: Add msmtp service. References: <20230420144230.9392-1-tanguy@bioneland.org> Date: Mon, 29 May 2023 23:43:14 +0200 In-Reply-To: (Tanguy Le Carrour's message of "Wed, 17 May 2023 10:51:44 +0200") Message-ID: <87ttvuerv1.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62969-done Cc: 62969-done@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Tanguy Le Carrour skribis: > * gnu/home/services/mail.scm: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > * doc/guix.texi (Mailing): New node. Sorry for the delay! I applied it with the changes below. The =E2=80=98define-maybe=E2=80=99 ch= ange fixes the unbound-variable warnings that we were seeing, and it lets us remove a bit of boilerplate. In a subsequent patch, we should make the msmtp package configurable, as is done for other services (see redshift, unclutter, dbus, etc.). I was going to do it but ran out of time; could you take a look? Thanks! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/home/services/mail.scm b/gnu/home/services/mail.scm index c3d34240f1..5445c82c67 100644 --- a/gnu/home/services/mail.scm +++ b/gnu/home/services/mail.scm @@ -18,11 +18,11 @@ (define-module (gnu home services mail) #:use-module (guix gexp) - #:use-module (gnu packages) #:use-module (gnu services) #:use-module (gnu services configuration) #:use-module (gnu home services) #:use-module (gnu home services shepherd) + #:use-module (gnu packages mail) #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -49,9 +49,9 @@ (define-module (gnu home services mail) msmtp-account-name msmtp-account-configuration)) -(define-maybe string) -(define-maybe boolean) -(define-maybe integer) +(define-maybe string (prefix msmtp-configuration-)) +(define-maybe boolean (prefix msmtp-configuration-)) +(define-maybe integer (prefix msmtp-configuration-)) ;; Serialization of 'msmtp'. (define (uglify-symbol field-name) @@ -61,15 +61,12 @@ (define (uglify-symbol field-name) (string-drop-right ugly-name 1) ugly-name))) -(define (msmtp-configuration-serialize-maybe-boolean field-name value) - #~(if #$(maybe-value-set? value) - (string-append #$(uglify-symbol field-name) " " (if #$value "on" "off") "\n") - "")) +(define (msmtp-configuration-serialize-boolean field-name value) + #~(string-append #$(uglify-symbol field-name) " " + (if #$value "on" "off") "\n")) -(define (msmtp-configuration-serialize-maybe-string field-name value) - #~(if #$(maybe-value-set? value) - (string-append #$(uglify-symbol field-name) " " #$value "\n") - "")) +(define (msmtp-configuration-serialize-string field-name value) + #~(string-append #$(uglify-symbol field-name) " " #$value "\n")) (define (msmtp-configuration-serialize-maybe-string-no-underscore field-name value) #~(if #$(maybe-value-set? value) @@ -77,10 +74,9 @@ (define (msmtp-configuration-serialize-maybe-string-no-underscore field-name val #$(string-replace-substring (uglify-symbol field-name) "_" "") " " #$value "\n") "")) -(define (msmtp-configuration-serialize-maybe-integer field-name value) - #~(if #$(maybe-value-set? value) - (string-append #$(uglify-symbol field-name) " " (number->string #$value) "\n") - "")) +(define (msmtp-configuration-serialize-integer field-name value) + #~(string-append #$(uglify-symbol field-name) " " + (number->string #$value) "\n")) (define (msmtp-configuration-serialize-extra-content field-name value) #~(if (string=? #$value "") "" (string-append #$value "\n"))) @@ -204,25 +200,22 @@ (define-configuration home-msmtp-configuration (prefix home-msmtp-configuration-)) -(define (home-msmtp-files-service config) +(define (home-msmtp-files config) (list `(".config/msmtp/config" - ,(mixed-text-file "config" + ,(mixed-text-file "msmtp-config" (serialize-configuration config home-msmtp-configuration-fields))))) -(define (home-msmtp-profile-service config) - (specifications->packages (list "msmtp"))) +(define (home-msmtp-profile-entries config) + (list msmtp)) (define home-msmtp-service-type (service-type (name 'home-msmtp) (extensions - (list - (service-extension - home-profile-service-type - home-msmtp-profile-service) - (service-extension - home-files-service-type - home-msmtp-files-service))) + (list (service-extension home-profile-service-type + home-msmtp-profile-entries) + (service-extension home-files-service-type + home-msmtp-files))) (default-value (home-msmtp-configuration)) (description "Configure msmtp, a simple @acronym{SMTP, Simple Mail Transfer Protocol} client that can relay email --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue May 30 02:54:22 2023 Received: (at 62969-done) by debbugs.gnu.org; 30 May 2023 06:54:22 +0000 Received: from localhost ([127.0.0.1]:59909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3tFN-0002Gy-RM for submit@debbugs.gnu.org; Tue, 30 May 2023 02:54:22 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:59711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3tFL-0002Gl-Nc for 62969-done@debbugs.gnu.org; Tue, 30 May 2023 02:54:20 -0400 X-GND-Sasl: tanguy@bioneland.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bioneland.org; s=gm1; t=1685429653; 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=8GeG9WjjSvQsZFr5VMTq0zZ3cYZbntDKGXcXRVb6tLk=; b=Mo0xc3ps4jPl3WjF7M3bsAK8Egj3olx31djj/C3CwViuIF9cDbrWgPjyICwlMHTQNp81tI GUnwcG/pTN8Y/HCgoLFsCt8qycN7cklueW5XGNwgLFu7Loz4E+PPcUqOPBtmJ2C9fJRBN3 vqs5MBRDQT3FqjAEFldgf0iuhg+s+Auo/B54h7Bm1NCroEJ1V4frAeiD4o071fKbZRkZ0q zq8NXlXnVKo6OddouGoVj9PDWm81Ugzz8LThIONb+vL5gZMKY0PG9Zc+YnC+rmFgQ78RLG mJ6+LRoy0LOGEosTEmyY6OIc7xGgzpMg/MtFqDnvmCMVXMWUwR4CqL9upBUH6w== X-GND-Sasl: tanguy@bioneland.org X-GND-Sasl: tanguy@bioneland.org Received: by mail.gandi.net (Postfix) with ESMTPSA id 039762000E; Tue, 30 May 2023 06:54:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable References: <20230420144230.9392-1-tanguy@bioneland.org> <87ttvuerv1.fsf_-_@gnu.org> Subject: Re: bug#62969: [PATCH] home: Add msmtp service. From: Tanguy LE CARROUR To: Ludovic =?utf-8?q?Court=C3=A8s?= In-Reply-To: <87ttvuerv1.fsf_-_@gnu.org> Date: Tue, 30 May 2023 08:54:12 +0200 Message-ID: <168542965253.3863.1458539807352226508@localhost> User-Agent: alot/0.10 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62969-done Cc: 62969-done@debbugs.gnu.org, mirai@makinata.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi Ludo=E2=80=99 Quoting Ludovic Court=C3=A8s (2023-05-29 23:43:14) > Tanguy Le Carrour skribis: >=20 > > * gnu/home/services/mail.scm: New file. > > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > > * doc/guix.texi (Mailing): New node. >=20 > Sorry for the delay! >=20 > I applied it with the changes below. The =E2=80=98define-maybe=E2=80=99 = change fixes > the unbound-variable warnings that we were seeing, and it lets us remove > a bit of boilerplate. Thaaaanks! > In a subsequent patch, we should make the msmtp package configurable, as > is done for other services (see redshift, unclutter, dbus, etc.). > I was going to do it but ran out of time; could you take a look? Absolutely! I submitted a simple one in order to have something to improve upon! =F0=9F=98=81 Cheers, --=20 Tanguy From unknown Sat Jun 21 10:41:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 27 Jun 2023 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator