diff options
| author | jdlugosz963 <jdlugosz963@gmail.com> | 2025-08-11 17:36:57 +0200 |
|---|---|---|
| committer | jdlugosz963 <jdlugosz963@gmail.com> | 2025-08-11 17:40:12 +0200 |
| commit | bc591dcedf45b80f70661f33c42c68dbd581e901 (patch) | |
| tree | 4a3cbd7831d8e0d8ce12f318d64e06848c9ea3ab /src/jd/features | |
| parent | 1ebb0e267b40d86386b66b7b81686461446e39f8 (diff) | |
| download | dotfiles-bc591dcedf45b80f70661f33c42c68dbd581e901.tar.gz dotfiles-bc591dcedf45b80f70661f33c42c68dbd581e901.zip | |
Migrate to RDE
Diffstat (limited to 'src/jd/features')
| -rw-r--r-- | src/jd/features/mail.scm | 115 | ||||
| -rw-r--r-- | src/jd/features/networking.scm | 81 |
2 files changed, 196 insertions, 0 deletions
diff --git a/src/jd/features/mail.scm b/src/jd/features/mail.scm new file mode 100644 index 0000000..f5c3536 --- /dev/null +++ b/src/jd/features/mail.scm | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | (define-module (jd features mail) | ||
| 2 | #:use-module (rde packages) | ||
| 3 | #:use-module (rde exceptions) | ||
| 4 | #:use-module (rde features) | ||
| 5 | #:use-module (rde predicates) | ||
| 6 | #:use-module (rde features emacs) | ||
| 7 | #:use-module (rde features mail) | ||
| 8 | #:use-module ((rde features mail providers) #:prefix mail-providers:) | ||
| 9 | #:use-module (gnu packages mail) | ||
| 10 | #:use-module (gnu packages emacs-xyz) | ||
| 11 | #:use-module (rde packages emacs-xyz) | ||
| 12 | #:use-module (rde packages mail) | ||
| 13 | #:use-module (rde serializers elisp) | ||
| 14 | #:use-module (rde home services mail) | ||
| 15 | #:use-module (gnu services) | ||
| 16 | #:use-module (gnu services configuration) | ||
| 17 | #:use-module (gnu home services) | ||
| 18 | #:use-module (gnu home-services mail) | ||
| 19 | #:use-module (gnu home services mcron) | ||
| 20 | #:use-module (gnu home-services version-control) | ||
| 21 | #:use-module (gnu home services xdg) | ||
| 22 | |||
| 23 | #:use-module (ice-9 match) | ||
| 24 | #:use-module (srfi srfi-1) | ||
| 25 | #:use-module (guix gexp) | ||
| 26 | #:use-module (guix deprecation) | ||
| 27 | #:use-module (guix diagnostics) | ||
| 28 | #:use-module (guix i18n) | ||
| 29 | |||
| 30 | #:export (feature-l2md* feature-mail-mcron)) | ||
| 31 | |||
| 32 | (define* (feature-l2md* | ||
| 33 | #:key | ||
| 34 | (l2md l2md)) | ||
| 35 | "Configure l2md MDA." | ||
| 36 | (ensure-pred file-like? l2md) | ||
| 37 | |||
| 38 | (define (get-home-services config) | ||
| 39 | (require-value 'mail-directory-fn config) | ||
| 40 | (require-value 'mailing-lists config) | ||
| 41 | (define mail-dir ((get-value 'mail-directory-fn config) config)) | ||
| 42 | (define mls (filter (lambda (x) (eq? (mailing-list-synchronizer x) 'l2md)) | ||
| 43 | (get-value 'mailing-lists config))) | ||
| 44 | (define (get-repo-config ml) | ||
| 45 | (let ((repo-config (mailing-list-config ml))) | ||
| 46 | (if (eq? %unset-value (l2md-repo-maildir repo-config)) | ||
| 47 | (l2md-repo | ||
| 48 | (inherit repo-config) | ||
| 49 | (maildir (string-append | ||
| 50 | mail-dir "/lists/" (mailing-list-fqda ml) "/archive"))) | ||
| 51 | repo-config))) | ||
| 52 | ;; <https://git.kernel.org/pub/scm/linux/kernel/git/dborkman/l2md.git/about/> | ||
| 53 | ;; Applying patches <https://git.kyleam.com/piem/about/> | ||
| 54 | |||
| 55 | (define add-ml-tag | ||
| 56 | (map (lambda (x) | ||
| 57 | (format | ||
| 58 | #f "notmuch tag +~a -- path:lists/~a/**" | ||
| 59 | ;; TODO: Use new tag not to retag already existing entities. | ||
| 60 | ;; Do it before new tag will be romved | ||
| 61 | ;; TODO: Fix order of items in post-new hook | ||
| 62 | (mailing-list-id x) (mailing-list-fqda x))) | ||
| 63 | mls)) | ||
| 64 | |||
| 65 | (list | ||
| 66 | (simple-service | ||
| 67 | 'l2md-add-tags-to-mailing-list | ||
| 68 | home-notmuch-service-type | ||
| 69 | (home-notmuch-extension | ||
| 70 | (post-new | ||
| 71 | (list | ||
| 72 | #~(begin (for-each system '#$add-ml-tag)))))) | ||
| 73 | |||
| 74 | (service | ||
| 75 | home-l2md-service-type | ||
| 76 | (home-l2md-configuration | ||
| 77 | (l2md l2md) | ||
| 78 | (oneshot 1) | ||
| 79 | (repos (map get-repo-config mls)))))) | ||
| 80 | |||
| 81 | (feature | ||
| 82 | (name 'l2md) | ||
| 83 | (home-services-getter get-home-services) | ||
| 84 | (values `((l2md . ,l2md))))) | ||
| 85 | |||
| 86 | (define* (feature-mail-mcron | ||
| 87 | #:key | ||
| 88 | (time-spec '(next-minute | ||
| 89 | (range 0 60 20)))) | ||
| 90 | "Configure mcron to invoke other email commands based on the other | ||
| 91 | features that have been enabled." | ||
| 92 | (define (get-home-services config) | ||
| 93 | (list | ||
| 94 | (when (get-value 'isync config) | ||
| 95 | (let* ((sync-cmd (list `(,((get-value 'mbsync config) config) "-a"))) | ||
| 96 | (notmuch-cmd (if (get-value 'notmuch config) | ||
| 97 | (list `(,(file-append (get-value 'notmuch config) "/bin/notmuch") | ||
| 98 | "new")) | ||
| 99 | (list))) | ||
| 100 | (l2md-cmd (if (get-value 'l2md config) | ||
| 101 | (list `(,(file-append (get-value 'l2md config) "/bin/l2md"))) | ||
| 102 | (list)))) | ||
| 103 | (simple-service | ||
| 104 | 'isync-mcron-job | ||
| 105 | home-mcron-service-type | ||
| 106 | (list | ||
| 107 | #~(job '#$time-spec | ||
| 108 | (lambda () | ||
| 109 | (setenv "DISPLAY" ":0") | ||
| 110 | #$@(map (lambda (x) `(system* ,@x)) | ||
| 111 | (append sync-cmd l2md-cmd notmuch-cmd)))))))))) | ||
| 112 | |||
| 113 | (feature | ||
| 114 | (name 'mail-mcron) | ||
| 115 | (home-services-getter get-home-services))) | ||
diff --git a/src/jd/features/networking.scm b/src/jd/features/networking.scm new file mode 100644 index 0000000..59eeb90 --- /dev/null +++ b/src/jd/features/networking.scm | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | (define-module (jd features networking) | ||
| 2 | #:use-module (rde features) | ||
| 3 | #:use-module (rde predicates) | ||
| 4 | |||
| 5 | #:use-module (gnu services) | ||
| 6 | #:use-module (gnu home services) | ||
| 7 | #:use-module (gnu home services shepherd) | ||
| 8 | #:use-module (rde home services i2p) | ||
| 9 | #:use-module (gnu services networking) | ||
| 10 | #:use-module (gnu system nss) | ||
| 11 | ;; #:use-module (rde system services networking) | ||
| 12 | #:use-module (rde system services accounts) | ||
| 13 | |||
| 14 | #:use-module (gnu packages i2p) | ||
| 15 | #:use-module (gnu packages networking) | ||
| 16 | #:use-module (gnu packages ssh) | ||
| 17 | #:use-module (gnu packages gnome) | ||
| 18 | #:use-module (rde packages) | ||
| 19 | |||
| 20 | #:use-module (guix gexp) | ||
| 21 | |||
| 22 | #:export (feature-networking*)) | ||
| 23 | |||
| 24 | (define* (feature-networking* | ||
| 25 | #:key | ||
| 26 | (iwd-autoconnect? #t) | ||
| 27 | (network-manager network-manager) | ||
| 28 | (network-manager-applet network-manager-applet) | ||
| 29 | (network-manager-vpn-plugins '()) | ||
| 30 | mdns?) | ||
| 31 | "Configure iwd and everything." | ||
| 32 | (ensure-pred file-like? network-manager) | ||
| 33 | (ensure-pred file-like? network-manager-applet) | ||
| 34 | |||
| 35 | (define f-name 'networking) | ||
| 36 | (define (get-home-services config) | ||
| 37 | |||
| 38 | (list | ||
| 39 | (simple-service 'network-manager-applet-package | ||
| 40 | home-profile-service-type | ||
| 41 | (list network-manager-applet)) | ||
| 42 | ;; TODO: Disable nm-applet notification by default | ||
| 43 | ;; gsettings set org.gnome.nm-applet disable-connected-notifications true | ||
| 44 | (simple-service | ||
| 45 | 'networking-nm-applet-shepherd-service | ||
| 46 | home-shepherd-service-type | ||
| 47 | (list | ||
| 48 | (shepherd-service | ||
| 49 | (provision '(nm-applet)) | ||
| 50 | (requirement '(dbus)) | ||
| 51 | (stop #~(make-kill-destructor)) | ||
| 52 | (start #~(make-forkexec-constructor | ||
| 53 | (list #$(file-append network-manager-applet "/bin/nm-applet") | ||
| 54 | "--indicator") | ||
| 55 | #:log-file (string-append | ||
| 56 | (getenv "XDG_STATE_HOME") "/log" | ||
| 57 | "/nm-applet.log")))))))) | ||
| 58 | |||
| 59 | (define (get-system-services config) | ||
| 60 | (list | ||
| 61 | (service network-manager-service-type | ||
| 62 | (network-manager-configuration | ||
| 63 | (network-manager network-manager) | ||
| 64 | (vpn-plugins network-manager-vpn-plugins) | ||
| 65 | (shepherd-requirement '(iwd)))) | ||
| 66 | (service (@@ (rde system services networking) iwd-service-type) | ||
| 67 | ((@@ (rde system services networking) iwd-configuration) | ||
| 68 | (main-conf | ||
| 69 | `((Settings ((AutoConnect . ,iwd-autoconnect?))))))) | ||
| 70 | (service modem-manager-service-type) | ||
| 71 | (service usb-modeswitch-service-type))) | ||
| 72 | |||
| 73 | (feature | ||
| 74 | (name f-name) | ||
| 75 | (values `((,f-name . #t) | ||
| 76 | ,@(if mdns? | ||
| 77 | `((name-service . ,%mdns-host-lookup-nss) | ||
| 78 | (mdns . #t)) | ||
| 79 | '()))) | ||
| 80 | (home-services-getter get-home-services) | ||
| 81 | (system-services-getter get-system-services))) | ||
