From patchwork Mon May 29 21:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 50473 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1C1C527BBE2; Mon, 29 May 2023 22:58:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D215F27BBF4 for ; Mon, 29 May 2023 22:44:29 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3ker-0002m3-TK; Mon, 29 May 2023 17:44:05 -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 1q3kep-0002lg-Kg for guix-patches@gnu.org; Mon, 29 May 2023 17:44: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 1q3keo-0001ID-FC for guix-patches@gnu.org; Mon, 29 May 2023 17:44:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3keo-0001EO-1l for guix-patches@gnu.org; Mon, 29 May 2023 17:44:02 -0400 Subject: bug#62969: [PATCH] home: Add msmtp service. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Mon, 29 May 2023 21:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 62969 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tanguy Le Carrour Cc: 62969-done@debbugs.gnu.org, mirai@makinata.eu Mail-Followup-To: 62969@debbugs.gnu.org, ludo@gnu.org, tanguy@bioneland.org Received: via spool by 62969-done@debbugs.gnu.org id=D62969.16853966284699 (code D ref 62969); Mon, 29 May 2023 21:44:01 +0000 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: Ludovic =?utf-8?q?Court=C3=A8s?= 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 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 ‘define-maybe’ change 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’. 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