From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id iCkSLZ5wQWRbjAAASxT56A (envelope-from ) for ; Thu, 20 Apr 2023 19:04:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8LIbLZ5wQWSTRAAA9RJhRA (envelope-from ) for ; Thu, 20 Apr 2023 19:04:30 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1F042C7A3 for ; Thu, 20 Apr 2023 19:04:30 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppXIN-0008TO-Es; Thu, 20 Apr 2023 12:38:07 -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 1ppXIJ-0008T9-0Y for guix-patches@gnu.org; Thu, 20 Apr 2023 12:38:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppXII-00087N-KZ for guix-patches@gnu.org; Thu, 20 Apr 2023 12:38:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ppXII-0004uK-B7 for guix-patches@gnu.org; Thu, 20 Apr 2023 12:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62969] [PATCH] home: Add msmtp service. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Apr 2023 16:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62969 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tanguy Le Carrour Cc: 62969@debbugs.gnu.org Received: via spool by 62969-submit@debbugs.gnu.org id=B62969.168200862918801 (code B ref 62969); Thu, 20 Apr 2023 16:38:02 +0000 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 Content-Language: en-US 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682010270; a=rsa-sha256; cv=none; b=jk+XTXiqQrR+gHtuf/yuknX7l4Y/ZTESE8B7yOdAxvXXeIfPKjuPzTqrdCY1/lPG+06e31 0iwc7UKCrRXrPSIX8y7o/7GvYcr4TyACyTgbO/zVjs2vA9r8FZY2meUoyVF8xBZKfhNwlz FBGzzLuKUQjWa1PTxYHNIYLDnfGg9fPiQR9x1IYAmuTu1ItIEgJFtckfxSq5azljjoDEYF Gcr9d/LayA1weA/xShd9qozoG8V2HURhVpsUe2FtBVbvWjniqnSrBg4Td3GJteP0byYczm R8gtgmEtPfZLzG2DusPinmyCgZ35ip3Vr64rjAH1zehXNyr8EJWLbRdu38xYVA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682010270; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=tAtI1sdRsQokdksiMkLzL/QYyew3mQX+5H64sX3nTxc=; b=l2lhIHx1JgAiD84FbczelM9QFKUY655852Y/qSNZU3hPB1pooXou0Cv1iN+6gTb1jHY0bz 9XeS8DThs2yJb/JSo9noXHCN3g6aVDbTXM291VzvsvMWwy9fI/ODyqFxDFm87/N55ex3ap DW+rSehdNX67BLuq0QKoEHp75GQ+Z7hnbuY5qPCp3+2Ou24I7XoZe0l6HFWPrJTe86NLi8 UEOBOXEfxVCf/EbYNp7jNk6nru2jAkblIgyt/4vsjv6kmIWabtV/h34T8erTtYPYGQ3BwH P/L/acWy/dzwpM1LWqcG/ihn0LAdi2Gn4Sf7+dchD5g96cBPum9sHGZyoYsx6g== X-Migadu-Spam-Score: -4.71 X-Spam-Score: -4.71 X-Migadu-Queue-Id: 1F042C7A3 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-TUID: pvg35z6XSVys 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