GNU bug report logs - #62969
[PATCH] home: Add msmtp service.

Previous Next

Package: guix-patches;

Reported by: Tanguy Le Carrour <tanguy <at> bioneland.org>

Date: Thu, 20 Apr 2023 14:44:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #34 received at 62969-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tanguy Le Carrour <tanguy <at> bioneland.org>
Cc: 62969-done <at> debbugs.gnu.org, mirai <at> makinata.eu
Subject: Re: bug#62969: [PATCH] home: Add msmtp service.
Date: Mon, 29 May 2023 23:43:14 +0200
[Message part 1 (text/plain, inline)]
Hi,

Tanguy Le Carrour <tanguy <at> bioneland.org> 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’.

[Message part 2 (text/x-patch, 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

This bug report was last modified 1 year and 359 days ago.

Previous Next


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