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.4 kB 77 lines
1{ self, ... }: 2{ 3 perSystem = 4 { 5 pkgs, 6 lib, 7 system, 8 ... 9 }: 10 { 11 packages.muchsync = self.libWithPkgs.${system}.makeWrapper pkgs.muchsync { 12 runtimeInputs = [ pkgs.notmuch ] ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.iputils ]; 13 env = { 14 NOTMUCH_CONFIG = 15 pkgs.writeText "notmuch-config" 16 self.packages.${pkgs.system}.mutt.passthru.notmuchConfig; 17 }; 18 wrapper = '' 19 20 # Create Maildir structure if it doesn't exist 21 mkdir -p "$HOME/Maildir"/{cur,new,tmp} 22 23 # Check if a host is reachable 24 check_host() { 25 local host=$1 26 ping -W2 -c1 "$host" >/dev/null 2>&1 27 } 28 29 # Smart host selection - try spora, nether, retiolum, then tor 30 find_green_host() { 31 if check_host green.s; then 32 echo "green.s" 33 elif check_host green.n; then 34 echo "green.n" 35 elif check_host green.r; then 36 echo "green.r" 37 else 38 echo "tor" 39 fi 40 } 41 42 # Check if arguments look like flags or a hostname 43 has_hostname=false 44 for arg in "$@"; do 45 case "$arg" in 46 -*) ;; # This is a flag 47 *) has_hostname=true; break ;; # Found a non-flag argument 48 esac 49 done 50 51 # If only flags provided (or no args), do a sync with green host 52 if [ "$has_hostname" = "false" ]; then 53 host=$(find_green_host) 54 echo "Syncing with $host..." >&2 55 56 if [ "$host" = "tor" ]; then 57 # Build dependencies lazily 58 echo "Building tornade..." >&2 59 tornade_path=$(nix build --no-link --print-out-paths "${self}#tornade") 60 clan_path=$(nix build --no-link --print-out-paths "${self}#clan-cli") 61 62 # Get tor hostname using clan CLI 63 tor_hostname=$(CLAN_DIR="${self}" "$clan_path/bin/clan" vars get green tor-ssh/tor-hostname) 64 65 # Use muchsync with custom ssh command via tornade 66 exec muchsync "$@" -s "$tornade_path/bin/tornade ssh" lass@"$tor_hostname" 67 else 68 exec muchsync "$@" lass@"$host" 69 fi 70 else 71 # Pass through arguments to muchsync 72 exec muchsync "$@" 73 fi 74 ''; 75 }; 76 }; 77}