Hey guix!

I am still working on extending guix's current opensmtpd-service with (guix 
records). 

I am getting fairly close to realizing that goal. For example this works:

(display (opensmtpd-configuration->mixed-text-file
 (let ([interface "wlp2s0"]
 [creds (opensmtpd-table
 (name "creds")
 (values
 (list
 (cons "joshua"
 
"$6$Ec4m8FgKjT2F/03Y$k66ABdse9TzCX6qaALB3WBL9GC1rmAWJmaoSjFMpbhzat7DOpFqpnOwpbZ34wwsQYIK8RQlqwM1I/v6vsRq86."))))]
 [receive-action (opensmtpd-action-local-delivery-configuration
 (name "receive")
 (method (opensmtpd-maildir-configuration
 (pathname "/home/%{rcpt.user}/Maildir")
 (junk #t)))
 (virtual "vusers"))]
 [smtp.gnucode.me (opensmtpd-pki
 (domain "smtp.gnucode.me")
 (cert "opensmtpd.scm")
 (key "opensmtpd.scm"))])
 (opensmtpd-configuration
 (mta-max-deferred 50)
 (queue
 (opensmtpd-queue-configuration
 (compression #t)))
 (smtp
 (opensmtpd-smtp-configuration
 (max-message-size "10M")))
 (srs
 (opensmtpd-srs-configuration
 (ttl-delay "5d")))
 (listen-ons
 (list
 ;; this forum help suggests that I listen on 0.0.0.0 and NOT eth0
 ;; https://serverfault.com/questions/726795/opensmtpd-wont-work-at-reboot
 ;; this listens for email from the outside world
 (opensmtpd-listen-on
 (interface interface)
 (port 25)
 (secure-connection "tls")
 (pki smtp.gnucode.me)
 )
 ;; this lets local users logged into the system via ssh send email
 (opensmtpd-listen-on
 (interface "lo")
 (port 25)
 (secure-connection "tls")
 (pki smtp.gnucode.me))
 (opensmtpd-listen-on
 (interface interface)
 (port 465)
 (secure-connection "smtps")
 (pki smtp.gnucode.me)
 (auth creds)
 ;;(filter )
 )
 (opensmtpd-listen-on
 (interface interface)
 (port 587)
 (secure-connection "tls-require")
 (pki smtp.gnucode.me)
 (auth creds)
 )))
 (matches (list
 (opensmtpd-match
 (action (opensmtpd-action-relay-configuration
 (name "send")))
 (for (opensmtpd-match-option-configuration
 (option "for any")))
 (from (opensmtpd-match-option-configuration
 (option "from any")))
 (auth (opensmtpd-match-option-configuration
 (option "auth"))))
 (opensmtpd-match
 (action receive-action)
 (from (opensmtpd-match-option-configuration
 (option "from any")))
 (for (opensmtpd-match-option-configuration
 (option "for domain")
 (value "gnucode.me"))
 ;;FIXME/TODO put in a table <vdoms> here
 ;;"for domain <vdoms>"
 ))
 (opensmtpd-match
 (action receive-action)
 (for (opensmtpd-match-option-configuration
 (option "for local"))))))))))

;; and it outputs:
smtp max-message-size 10M
srs ttl 5d
queue compression

mta max-deferred 50

pki smtp.gnucode.me cert "opensmtpd.scm"
pki smtp.gnucode.me key "opensmtpd.scm"

listen on wlp2s0 tls port 25 pki smtp.gnucode.me
listen on lo tls port 25 pki smtp.gnucode.me
listen on wlp2s0 smtps port 465 pki smtp.gnucode.me auth <creds>
listen on wlp2s0 tls-require port 587 pki smtp.gnucode.me auth <creds>

action "send" relay
action "receive" maildir "/home/%{rcpt.user}/Maildir" junk virtual <vusers> 

match from any for any auth action "send"
match from any for domain gnucode.me action "receive"
match for local action "receive"
My question has to do with how I am handling the opensmtpd filters...Some of 
the opensmtpd filter
commands execute programs. I would like to get some advice about how to let 
some of the
<opensmtpd-configuration>'s fieldnames be gexps. My current opensmtpd.scm file 
does so:

https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.scm
 
(https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.scm)

(though I am getting some errors with the procedure

        create-etc-dkimsign-key-file. I should probable use the guix's 
etc-service instead). Anyway, Right now I am using a LOT of code like  
(mixed-text-file (string-append variable (string-append (function 
(string-append (another-function ...))))

I suppose I should instead change this to

(define my-list (list (function ...) (function ...) (list (function (list 
(function ...) (function ...))))

(mixed-text-file (apply string-append (flatten my-list))) 
BUT that doesn't quite answer my issue. It would be helpful to allow some 
<opensmtpd-configuration>'s
fieldnames accept gexps. How would I allow go about doing that?

I think that the answer would be to use guix's mixed-text-file*, but I am not 
sure how to do that elegantly...

My current code is here:

https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd-records.scm
 
(https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd-records.scm)

Perhaps a more targeted question would be how do I modify the current procedure

        opensmtpd-filter-proc-exec->string record to accept gexps?  

Suggestions are most welcome.

My thoughts about the service are here: 

https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.org
 
(https://notabug.org/jbranso/linode-guix-system-configuration/src/master/opensmtpd.org)
Thanks,

Joshua

Reply via email to