This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / muchsync / flake-module.nix
2.3 kB 66 lines
1{ self, inputs, ... }: 2{ 3 perSystem = 4 { 5 pkgs, 6 lib, 7 ... 8 }: 9 { 10 packages.muchsync = inputs.wrappers.lib.wrapPackage { 11 pkgs = pkgs; 12 package = pkgs.muchsync; 13 runtimeInputs = [ pkgs.notmuch ] ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.iputils ]; 14 env = { 15 NOTMUCH_CONFIG = self.packages.${pkgs.system}.notmuch.passthru.configuration.configFile.path; 16 }; 17 wrapper = 18 { exePath, envString, ... }: 19 '' 20 ${envString} 21 # Create Maildir structure if it doesn't exist 22 mkdir -p "$HOME/Maildir"/{cur,new,tmp} 23 24 MUCHSYNC_HOST="neoprism.lassul.us" 25 MUCHSYNC_SSH="ssh -p 45621" 26 27 # Check if we should do auto-sync 28 # Auto-sync if no args or only verbose/config flags 29 auto_sync=false 30 if [ $# -eq 0 ]; then 31 auto_sync=true 32 else 33 # Check if all args are sync-compatible flags 34 all_sync_flags=true 35 for arg in "$@"; do 36 case "$arg" in 37 -v|-vv|-vvv|--verbose) 38 set -x # Enable shell debugging for verbose mode 39 ;; # Verbose flags 40 --config|--config=*) ;; # Config flags 41 -*) all_sync_flags=false; break ;; # Unknown flag, don't auto-sync 42 *) all_sync_flags=false; break ;; # Non-flag argument, don't auto-sync 43 esac 44 done 45 if [ "$all_sync_flags" = true ]; then 46 auto_sync=true 47 fi 48 fi 49 50 if [ "$auto_sync" = true ]; then 51 # Move archived messages from INBOX to archive folder 52 mkdir -p "$HOME/Maildir/.archive"/{cur,new,tmp} 53 notmuch search --output=files 'tag:archive AND folder:"" AND NOT folder:.archive' | while IFS= read -r f; do 54 [ -f "$f" ] && mv "$f" "$HOME/Maildir/.archive/cur/" 55 done 56 notmuch new --quiet 2>/dev/null 57 58 ${exePath} -s "$MUCHSYNC_SSH" "$@" lass@"$MUCHSYNC_HOST" 59 else 60 # Pass through arguments to muchsync 61 exec ${exePath} "$@" 62 fi 63 ''; 64 }; 65 }; 66}