diff --git a/guix/home-services/mail.scm b/guix/home-services/mail.scm new file mode 100644 index 0000000..5275aaf --- /dev/null +++ b/guix/home-services/mail.scm @@ -0,0 +1,233 @@ + +;;; +;;; feature-isync. +;;; + +(define (prep-str sym str) + (symbol-append sym '- (string->symbol str))) + +(define (isync-channel id local remote) + `((Channel ,(prep-str id local)) + (Near ,(format #f ":~a-local:~a" id local)) + (Far ,(format #f ":~a-remote:~a" id remote)) + ,#~"")) + +(define (isync-group-with-channels id isync-mapping) + (append + (append-map + (lambda (x) (isync-channel id (car x) (cdr x))) + isync-mapping) + `((Group ,(symbol-append id)) + ,@(map + (lambda (x) (list 'Channel (prep-str id (car x)))) + isync-mapping) + ,#~""))) + +(define* (generate-isync-serializer + host folders-mapping + #:key + (port #f) + (auth-mechs #f) + (subfolders 'Verbatim) + (cipher-string #f) + (pipeline-depth #f)) + (ensure-pred symbol? subfolders) + + (define (isync-settings mail-directory mail-account) + (let* ((id (mail-account-id mail-account)) + (user (or (mail-account-user mail-account) + (mail-account-fqda mail-account))) + (pass-cmd (mail-account-get-pass-cmd mail-account))) + `(,#~(string-append "# Account '" #$(symbol->string id) + " starts here") + (IMAPAccount ,id) + (Host ,host) + ,@(if (integer? port) `((Port ,port)) '()) + (User ,user) + (PassCmd ,pass-cmd) + ,@(if (symbol? auth-mechs) `((AuthMechs ,auth-mechs)) '()) + (SSLType IMAPS) + (CertificateFile /etc/ssl/certs/ca-certificates.crt) + ,@(if (symbol? cipher-string) `((CipherString ,cipher-string)) '()) + ,@(if (integer? pipeline-depth) `((PipelineDepth ,pipeline-depth)) '()) + ,#~"" + (IMAPStore ,(symbol-append id '-remote)) + (Account ,id) + ,#~"" + (MaildirStore ,(symbol-append id '-local)) + (SubFolders ,subfolders) + (Path ,(string-append mail-directory "/accounts/" user "/")) + (Inbox ,(string-append mail-directory "/accounts/" user "/inbox")) + ,#~"" + ,@(isync-group-with-channels id folders-mapping)))) + isync-settings) + +;; Directory names has lowercased spelling to match notmuch tags +(define gmail-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "[Gmail]/Sent Mail") + ("drafts" . "[Gmail]/Drafts") + ("archive" . "[Gmail]/All Mail") + ("trash" . "[Gmail]/Trash") + ("spam" . "[Gmail]/Spam"))) + +(define gandi-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "Sent") + ("drafts" . "Drafts") + ("archive" . "Archive") + ("trash" . "Trash") + ("spam" . "Junk"))) + +(define gmx-fr-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "Envoy&AOk-s") + ("drafts" . "Brouillons") + ("archive" . "Archive") + ("trash" . "Corbeille") + ("spam" . "Junk"))) + +(define outlook-fr-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "&AMk-l&AOk-ments envoy&AOk-s") ;"Éléments envoyés" + ("drafts" . "Brouillons") + ("archive" . "Notes") + ("trash" . "&AMk-l&AOk-ments supprim&AOk-s") ;"Éléments supprimés" + ("spam" . "Courrier ind&AOk-sirable"))) ;"Courrier indésirable" + +(define mailbox-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "Sent") + ("drafts" . "Drafts") + ("trash" . "Trash") + ("junk" . "Junk") + ("archive" . "Archive"))) + +(define hosteurope-de-folder-mapping + '(("inbox" . "INBOX") + ("sent" . "Sent") + ("drafts" . "Entwurf") + ("trash" . "Trash") + ("spam" . "Spam") + ("archive" . "All"))) + +(define gmx-fr-isync-settings + (generate-isync-serializer "imap.gmx.net" gmx-fr-folder-mapping)) + +(define ovh-isync-settings + (generate-isync-serializer "ssl0.ovh.net" gandi-folder-mapping + #:subfolders 'Legacy + #:auth-mechs 'LOGIN)) + +(define gmail-isync-settings + (generate-isync-serializer "imap.gmail.com" gmail-folder-mapping)) + +(define gandi-isync-settings + (generate-isync-serializer "mail.gandi.net" gandi-folder-mapping)) + +(define mailbox-isync-settings + (generate-isync-serializer "imap.mailbox.org" mailbox-folder-mapping)) + +(define hosteurope-de-isync-settings + (generate-isync-serializer "imap.hosteurope.de" hosteurope-de-folder-mapping)) + +(define* (get-ovh-pro-isync-settings + #:key + (folder-mapping #f) + (host-number #f)) + (ensure-pred list? folder-mapping) + (generate-isync-serializer + (string-append "pro" host-number ".mail.ovh.net") + folder-mapping + #:auth-mechs 'LOGIN + #:subfolders 'Legacy)) + +(define ovh-pro2-fr-isync-settings + (get-ovh-pro-isync-settings + #:host-number "2" + #:folder-mapping outlook-fr-folder-mapping)) + +(define (generic-isync-settings mail-directory mail-account) + (let* ((user (mail-account-fqda mail-account))) + `(,#~"# Do not know how to serialize generic accounts :(" + ,#~(format #f "# ~a wasn't configured by rde," #$user) + ,#~"# Try to set another value for mail-account's type field."))) + +(define %default-isync-serializers + `((gmail . ,gmail-isync-settings) + (gandi . ,gandi-isync-settings) + (gmx-fr . ,gmx-fr-isync-settings) + (ovh . ,ovh-isync-settings) + (ovh-pro2-fr . ,ovh-pro2-fr-isync-settings) + (mailbox . ,mailbox-isync-settings) + (hosteurope-de . ,hosteurope-de-isync-settings) + (generic . ,generic-isync-settings))) + +(define default-isync-global-settings + `((Create Both) + (Expunge Both) + (SyncState *) + ,#~"")) + +(define* (feature-isync + #:key + (mail-account-ids #f) + (isync-global-settings default-isync-global-settings) + (isync-serializers %default-isync-serializers) + (isync-verbose #f)) + "Setup and configure isync. If MAIL-ACCOUNT-IDS not provided use all +mail accounts. ISYNC-VERBOSE controls output verboseness of +@file{mbsync}." + (ensure-pred maybe-list? mail-account-ids) + (ensure-pred list? isync-serializers) + (ensure-pred list? isync-global-settings) + + ;; Sync mail deletion + ;; https://notmuchmail.org/pipermail/notmuch/2016/023112.html + ;; http://tiborsimko.org/mbsync-duplicate-uid.html + + ;; https://notmuchmail.org/emacstips/#index25h2 + + (define (get-home-services config) + (require-value 'mail-accounts config + "feature-isync can't operate without mail-accounts.") + + (let* ((mail-accounts + (filter (lambda (x) (eq? (mail-account-synchronizer x) 'isync)) + (get-value 'mail-accounts config))) + (mail-directory-fn (get-value 'mail-directory-fn config)) + (mail-directory (mail-directory-fn config))) + + (define (serialize-mail-acc mail-acc) + ((assoc-ref isync-serializers (mail-account-type mail-acc)) + 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 + (config + (append + isync-global-settings + (append-map serialize-mail-acc mail-accounts)))))))) + + ;; MAYBE: Wrap it in a program-file to make it possible to call it + ;; with system* + (define (isync-synchronize-cmd-fn mail-acc) + (string-append "mbsync " + (if isync-verbose "-V " "") + (symbol->string (mail-account-id mail-acc)))) + + (feature + (name 'isync) + (values `((isync . #t) + (isync-synchronize-cmd-fn . ,isync-synchronize-cmd-fn))) + (home-services-getter get-home-services))) diff --git a/guix/home.nix b/guix/home.nix index 121f285..1cbd510 100644 --- a/guix/home.nix +++ b/guix/home.nix @@ -11,6 +11,9 @@ starship # The guix version of dolphin isn't built for wayland and can't find the icon theme dolphin + ark + pmbootstrap + element-desktop ]; programs.firefox = { @@ -30,4 +33,91 @@ home.file.".mozilla/native-messaging-hosts".source = "/home/chris/.nix-profile/lib/mozilla/native-messaging-hosts"; + + accounts.email = { + maildirBasePath = "mail"; + accounts = { + personal = { + address = "chris@cochrun.xyz"; + userName = "chris@cochrun.xyz"; + mbsync.enable = true; + mu.enable = true; + flavor = "plain"; + primary = true; + passwordCommand = "rbw get 'Office 365'"; + realName = "Chris Cochrun"; + signature = { + text = '' + Praising God in all things, + Chris Cochrun + ''; + delimiter = '' + *** + ''; + showSignature = "append"; + }; + imap = { + host = "mail.cochrun.xyz"; + port = 993; + tls.enable = true; + }; + smtp = { + host = "mail.cochrun.xyz"; + port = 25; + tls.enable = true; + }; + mbsync = { + create = "maildir"; + remove = "both"; + expunge = "both"; + }; + maildir.path = "cochrun"; + }; + + work = { + address = "chris@tfcconnection.org"; + userName = "chris@tfcconnection.org"; + mbsync.enable = true; + mu.enable = true; + flavor = "outlook.office365.com"; + passwordCommand = "mailpass"; + realName = "Chris Cochrun"; + imap = { + host = "outlook.office365.com"; + port = 993; + tls.enable = true; + }; + smtp = { + host = "smtp.office365.com"; + port = 587; + tls.enable = true; + }; + mbsync = { + create = "maildir"; + remove = "both"; + expunge = "both"; + extraConfig.account = { + AuthMechs = "LOGIN"; + }; + }; + maildir.path = "office"; + signature = { + text = '' + Praising God in all things, + Chris Cochrun + ''; + delimiter = '' + *** + ''; + showSignature = "append"; + }; + }; + }; + }; + + programs.mbsync = { + enable = true; + }; + programs.msmtp.enable = true; + services.mbsync.enable = true; } diff --git a/guix/home.scm b/guix/home.scm index 57e2432..fa87407 100644 --- a/guix/home.scm +++ b/guix/home.scm @@ -75,12 +75,23 @@ marked files in a dired buffer via rsync.")))) "mpv" "mpv-mpris" "yt-dlp" + "playerctl" + "gstreamer" + "gst-plugins-base" + "gst-plugins-good" + "gst-plugins-bad" + "gst-plugins-ugly" + "gst-libav" + "alsa-utils" + "pavucontrol" + "v4l-utils" "tmux" "direnv" "dutree" "btop" "htop" "ripgrep" + "bat" "alacritty" "libnotify" "nextcloud-client" @@ -96,17 +107,20 @@ marked files in a dired buffer via rsync.")))) "slurp" "imv" "openjdk" - ;; "dolphin" "kwallet" "kwallet-pam" "breeze" "breeze-icons" "kdeconnect" + "qtwayland@5.15.8" + ;; "qtwayland" + "egl-wayland" "pinentry" "pinentry-qt" "pinentry-gnome3" "pinentry-rofi" "pulsemixer" + "pamixer" "python-pulsectl" "dunst" "rbw" @@ -120,6 +134,7 @@ marked files in a dired buffer via rsync.")))) "brightnessctl" "flatpak" "flatpak-xdg-utils" + "sound-theme-freedesktop" "xdg-utils" "xdg-desktop-portal" "xdg-desktop-portal-kde" @@ -129,6 +144,9 @@ marked files in a dired buffer via rsync.")))) "enchant" "blesh" "ncurses" + "transmission" + + ;; Emacs and packages "emacs-next-pgtk" "emacs-dired-rsync" "emacs-all-the-icons" @@ -140,7 +158,10 @@ marked files in a dired buffer via rsync.")))) "emacs-org" "emacs-elfeed" "emacs-elfeed-org" + "emacs-esh-autosuggest" "emacs-use-package" + "emacs-exec-path-from-shell" + "emacs-langtool" "emacs-general" "emacs-evil" "emacs-evil-collection" @@ -157,11 +178,18 @@ marked files in a dired buffer via rsync.")))) "emacs-org-modern" "emacs-org-web-tools" "emacs-org-re-reveal" + "emacs-org-ql" + "emacs-org-msg" + "emacs-calfw" + "emacs-transmission" "emacs-emojify" "emacs-pulsar" "emacs-vertico" "emacs-consult" + "emacs-consult-eglot" + "emacs-consult-org-roam" "emacs-tempel" + "emacs-tempel-collection" "emacs-marginalia" "emacs-embark" "emacs-wgrep" @@ -175,22 +203,41 @@ marked files in a dired buffer via rsync.")))) "emacs-direnv" "emacs-diredfl" "emacs-pdf-tools" + "emacs-vterm" "emacs-plz" "emacs-ement" + "emacs-bongo" + "emacs-emms" "emacs-gcmh" "emacs-visual-fill-column" "emacs-eat" + "emacs-mpv" "emacs-all-the-icons-dired" "emacs-all-the-icons-completion" "emacs-org-super-agenda" "emacs-toc-org" + "emacs-ox-reveal" + "emacs-ox-pandoc" + "emacs-ox-hugo" "emacs-dired-sidebar" + "emacs-dired-du" "emacs-ledger-mode" + "emacs-rustic" + "emacs-lua-mode" + "emacs-fennel-mode" + "emacs-web-mode" + "emacs-yaml-mode" + "emacs-cmake-mode" + "emacs-typescript-mode" + "emacs-fish-mode" + "emacs-markdown-mode" + "emacs-restclient" "emacs-ob-restclient" "emacs-guix" "emacs-nix-mode" "emacs-helpful" ;; "emacs-mu4e" + "isync" "mu" ))) @@ -201,11 +248,23 @@ marked files in a dired buffer via rsync.")))) (home-bash-configuration (guix-defaults? #t) (aliases '(("grep" . "grep --color=auto") - ("gh" . "guix home reconfigure ~/dotfiles/guix/home.scm") - ("gs" . "guix system reconfigure ~/dotfiles/guix/system.scm"))) + ("gh" . "guix home -L ~/dotfiles/guix reconfigure ~/dotfiles/guix/home.scm") + ("gs" . "sudo guix system -L /home/chris/dotfiles/guix reconfigure /home/chris/dotfiles/guix/syl.scm"))) (environment-variables '(("QT_QPA_PLATFORM" . "wayland") - ("QT_QPA_PLATFORMTHEME" . "qt5ct"))) + ("QT_QPA_PLATFORMTHEME" . "qt5ct") + ("XDG_DATA_DIRS" . "$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share") + ("RTC_USE_PIPEWIRE" . "true") + ("GDK_BACKEND" . "wayland") + ("WLR_DRM_NO_ATOMIC" . "1") + ("MOZ_ENABLE_WAYLAND" . "1") + ("WLR_BACKEND" . "vulkan") + ("WLR_RENDERER" . "vulkan") + ("SDL_VIDEODRIVER" . "wayland") + ("WLR_NO_HARDWARE_CURSORS" . "1") + ("GTK_USE_PORTAL" . "1") + ("EDITOR" . "emacsclient -t -a") + ("VISUAL" . "emacsclient -c -a"))) (bashrc (list (plain-file "blesh" "source .guix-home/profile/share/blesh/ble.sh") (plain-file "home-manager" "source .nix-profile/etc/profile.d/hm-session-vars.sh") ;;These need to be here so they are at the bottom and therefore after guix-defaults @@ -217,14 +276,19 @@ marked files in a dired buffer via rsync.")))) (simple-service 'extra-env-vars home-environment-variables-service-type `(("PATH" . "$PATH:/home/chris/bin:/home/chris/.nix-profile/bin") - ("QT_QPA_PLATFORM" . "wayland") + ("QT_QPA_PLATFORM" . "wayland-egl") + ("SDL_VIDEODRIVER" . "wayland") + ("MOZ_ENABLE_WAYLAND" . "1") + ("CLUTTER_BACKEND" . "wayland") + ("ELM_ENGINE" . "wayland_egl") + ("ECORE_EVAS_ENGINE" . "wayland-egl") ("QT_QPA_PLATFORMTHEME" . "qt5ct") ("LITERAL_VALUE" . ,(literal-string "${abc}")))) (service home-fish-service-type (home-fish-configuration (aliases '(("ls" . "exa -l") - ("gh" . "guix home reconfigure ~/dotfiles/guix/home.scm") - ("gs" . "guix system reconfigure ~/dotfiles/guix/system.scm"))))) + ("gh" . "guix home -L ~/dotfiles/guix reconfigure ~/dotfiles/guix/home.scm") + ("gs" . "sudo guix system -L /home/chris/dotfiles/guix reconfigure /home/chris/dotfiles/guix/syl.scm"))))) (simple-service 'config home-xdg-configuration-files-service-type `(("hypr" ,(local-file "../.config/hypr" #:recursive? #t)) diff --git a/guix/system.scm b/guix/syl.scm similarity index 86% rename from guix/system.scm rename to guix/syl.scm index 8791654..f19d64f 100644 --- a/guix/system.scm +++ b/guix/syl.scm @@ -9,16 +9,19 @@ ;; Indicate which modules to import to access the variables ;; used in this configuration. -(use-modules (gnu) - (gnu services) - (gnu services shepherd) - (gnu services dbus) - (gnu system) - (gnu system setuid) - (gnu system nss) - (rosenthal packages wm) - (nongnu packages linux) - (nongnu system linux-initrd)) +(define-module (syl) + #:use-module (gnu) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (gnu services dbus) + #:use-module (gnu system) + #:use-module (gnu system setuid) + #:use-module (gnu system nss) + #:use-module (gnu system shadow) + #:use-module (gnu packages android) + #:use-module (rosenthal packages wm) + #:use-module (nongnu packages linux) + #:use-module (nongnu system linux-initrd)) (use-service-modules cups desktop networking ssh xorg avahi admin base nix dbus pm audio virtualization sysctl) @@ -69,9 +72,11 @@ YOUR-USER-NAME ALL=(ALL) NOPASSWD:/run/current-system/profile/bin/chvt,/run/cur (comment "Chris") (group "users") (home-directory "/home/chris") - (supplementary-groups '("wheel" "netdev" "tty" "audio" "video"))) + (supplementary-groups '("wheel" "netdev" "tty" "audio" "video" "adbusers"))) %base-user-accounts)) + + (sudoers-file etc-sudoers-config) ;; Packages installed system-wide. Users can also install packages @@ -81,6 +86,17 @@ YOUR-USER-NAME ALL=(ALL) NOPASSWD:/run/current-system/profile/bin/chvt,/run/cur (specification->package "sway") (specification->package "dbus-glib") (specification->package "hyprland") + (specification->package "libvdpau") + (specification->package "android-udev-rules") + (specification->package "adb") + (specification->package "fastboot") + (specification->package "vulkan-tools") + (specification->package "vulkan-headers") + (specification->package "libva") + (specification->package "libva-utils") + (specification->package "intel-vaapi-driver") + (specification->package "libvdpau") + (specification->package "libvdpau-va-gl") (specification->package "emacs-next-pgtk")) %base-packages)) @@ -102,6 +118,8 @@ YOUR-USER-NAME ALL=(ALL) NOPASSWD:/run/current-system/profile/bin/chvt,/run/cur (simple-service 'mtp udev-service-type (list libmtp)) (udev-rules-service 'pipewire-add-udev-rules pipewire) (udev-rules-service 'brightnessctl-udev-rules brightnessctl) + (udev-rules-service 'android android-udev-rules + #:groups '("adbusers")) (service nix-service-type) diff --git a/scripts/voldown b/scripts/voldown index 6178360..1ca2004 100755 --- a/scripts/voldown +++ b/scripts/voldown @@ -3,7 +3,7 @@ # killall volup # killall voldown pamixer --allow-boost -d 5 -pw-play /run/current-system/sw/share/sounds/freedesktop/stereo/audio-volume-change.oga & +pw-play ~/.guix-home/profile/share/sounds/freedesktop/stereo/audio-volume-change.oga & volume=$(pulsemixer --get-volume | awk '{print $1}') echo $volume > /tmp/vol diff --git a/scripts/volup b/scripts/volup index bd872ff..ea3a53a 100755 --- a/scripts/volup +++ b/scripts/volup @@ -3,7 +3,7 @@ # killall volup # killall voldown pamixer --allow-boost -i 5 -pw-play /run/current-system/sw/share/sounds/freedesktop/stereo/audio-volume-change.oga & +pw-play ~/.guix-home/profile/share/sounds/freedesktop/stereo/audio-volume-change.oga & volume=$(pulsemixer --get-volume | awk '{print $1}') echo $volume > /tmp/vol