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