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
3.1 kB 91 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 # Check if a host is reachable 25 check_host() { 26 local host=$1 27 ping -W2 -c3 "$host" >/dev/null 2>&1 28 } 29 30 # Smart host selection - try spora, nether, retiolum, then tor 31 find_green_host() { 32 if check_host green.s; then 33 echo "green.s" 34 elif check_host green.n; then 35 echo "green.n" 36 elif check_host green.r; then 37 echo "green.r" 38 else 39 echo "tor" 40 fi 41 } 42 43 # Check if we should do auto-sync 44 # Auto-sync if no args or only verbose/config flags 45 auto_sync=false 46 if [ $# -eq 0 ]; then 47 auto_sync=true 48 else 49 # Check if all args are sync-compatible flags 50 all_sync_flags=true 51 for arg in "$@"; do 52 case "$arg" in 53 -v|-vv|-vvv|--verbose) 54 set -x # Enable shell debugging for verbose mode 55 ;; # Verbose flags 56 --config|--config=*) ;; # Config flags 57 -*) all_sync_flags=false; break ;; # Unknown flag, don't auto-sync 58 *) all_sync_flags=false; break ;; # Non-flag argument, don't auto-sync 59 esac 60 done 61 if [ "$all_sync_flags" = true ]; then 62 auto_sync=true 63 fi 64 fi 65 66 if [ "$auto_sync" = true ]; then 67 host=$(find_green_host) 68 echo "Syncing with $host..." >&2 69 70 if [ "$host" = "tor" ]; then 71 # Build dependencies lazily 72 echo "Building tornade..." >&2 73 tornade_path=$(nix build --no-link --print-out-paths "${self}#tornade") 74 clan_path=$(nix build --no-link --print-out-paths "${self}#clan-cli") 75 76 # Get tor hostname using clan CLI 77 tor_hostname=$(CLAN_DIR="${self}" "$clan_path/bin/clan" vars get green tor-ssh/hostname) 78 79 # Use muchsync with custom ssh command via tornade 80 exec ${exePath} -s "$tornade_path/bin/tornade ssh" "$@" lass@"$tor_hostname" 81 else 82 exec ${exePath} "$@" lass@"$host" 83 fi 84 else 85 # Pass through arguments to muchsync 86 exec ${exePath} "$@" 87 fi 88 ''; 89 }; 90 }; 91}