diff mbox series

bug#62969: [PATCH] home: Add msmtp service.

Message ID 87ttvuerv1.fsf_-_@gnu.org
State New
Headers show
Series bug#62969: [PATCH] home: Add msmtp service. | expand

Commit Message

Ludovic Courtès May 29, 2023, 9:43 p.m. UTC
Hi,

Tanguy Le Carrour <tanguy@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’.

Comments

Tanguy LE CARROUR May 30, 2023, 6:54 a.m. UTC | #1
Hi Ludo’


Quoting Ludovic Courtès (2023-05-29 23:43:14)
> Tanguy Le Carrour <tanguy@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.

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! 😁

Cheers,
diff mbox series

Patch

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