Skip to content

Commit

Permalink
rde: mail: Ensure mail dirs for accounts created during activation.
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdw committed Nov 26, 2021
1 parent 3427fd2 commit 1f1b52c
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions rde/features/mail.scm
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ logfile \"~/.local/var/log/msmtp.log\"\n")
(home-services-getter get-home-services)
(values `((msmtp . #t)))))


;;;
;;; feature-l2md.
;;;

(define* (feature-l2md)
"Configure l2md MDA."
(define (get-home-services config)
Expand Down Expand Up @@ -307,6 +312,11 @@ logfile \"~/.local/var/log/msmtp.log\"\n")
(home-services-getter get-home-services)
(values `((l2md . #t)))))


;;;
;;; feature-isync.
;;;

(define (prep-str sym str)
(symbol-append sym '- (string->symbol str)))

Expand Down Expand Up @@ -414,6 +424,14 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
mail-directory mail-acc))

(list
(simple-service
'isync-ensure-mail-dirs-exists
home-activation-service-type
#~(map mkdir-p
'#$(map (lambda (acc)
(string-append mail-directory "/accounts/"
(mail-account-fqda acc)))
mail-accounts)))
(service
home-isync-service-type
(home-isync-configuration
Expand All @@ -435,6 +453,10 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
(isync-synchronize-cmd-fn . ,isync-synchronize-cmd-fn)))
(home-services-getter get-home-services)))


;;;
;;; feature-notmuch.
;;;

(define (default-get-notmuch-configuration config)
(require-value 'mail-settings config)
Expand All @@ -443,10 +465,7 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
(define mail-accounts (get-value 'mail-accounts config))
(define emails (map mail-account-fqda mail-accounts))
(define ids (map mail-account-id mail-accounts))

(define mail-directory ((get-value 'mail-directory-fn config) config))
(define (mail-dir email) (string-append mail-directory "/" email))
(define mail-directories (map mail-dir emails))

(define (sync-cmd ma)
((get-value
Expand Down Expand Up @@ -491,7 +510,7 @@ $(echo $f | sed 's;/~a/;/all/;' | sed 's/,U=[0-9]*:/:/'); done"

(define* (move-in-tagged-messages
tag
#:optional (exclude-dir "nothing-will-match-this"))
#:key (exclude-dir "nothing-will-match-this"))
(format #f "for f in $(notmuch search --output=files \
'not path:/.*\\/~a/ and tag:~a' | grep -v \"/~a/\"); \
do mv -v $f \
Expand All @@ -504,18 +523,15 @@ $(echo $f | sed 's;/[[:alnum:]]*/cur/;/~a/cur/;' | sed 's/,U=[0-9]*:/:/'); done"
(append
(map move-out-untagged-messages '(inbox trash spam))
(map move-in-tagged-messages '(trash spam))
(list (move-in-tagged-messages 'inbox "all")
(list (move-in-tagged-messages 'inbox #:exclude-dir "all")
delete-deleted-messages)))

(home-notmuch-extension
(pre-new
(list
(with-imported-modules '((guix build utils))
#~(begin
(map (@@ (guix build utils) mkdir-p) '#$mail-directories)
(for-each system '#$move-rules)
;; (for-each system '#$sync-cmds)
))))
(for-each system '#$move-rules)))))
(post-new
(list
#~(begin (for-each system '#$make-id-tag)
Expand Down

0 comments on commit 1f1b52c

Please sign in to comment.