Flake to setup a local env for atproto development
8
fork

Configure Feed

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

Add tmux session

+87 -27
+87 -27
flake.nix
··· 50 50 echo "Files created:" 51 51 ls -la . 52 52 ''; 53 + 54 + # Script to start all services in tmux 55 + all = pkgs.writeShellScriptBin "all" '' 56 + set -e 57 + 58 + # Check if tmux is available 59 + if ! command -v tmux >/dev/null 2>&1; then 60 + echo "❌ tmux is not installed. Please install tmux first." 61 + exit 1 62 + fi 63 + 64 + # Check if certificates exist 65 + if [ ! -f "./certs/cert.pem" ]; then 66 + echo "⚠️ WARNING: SSL certificates not found. Run 'nix run .#generate-certs' first." 67 + read -p "Continue anyway? (y/N): " -n 1 -r 68 + echo 69 + if [[ ! $REPLY =~ ^[Yy]$ ]]; then 70 + exit 1 71 + fi 72 + fi 73 + 74 + # Check if hosts file is configured 75 + if ! grep -q "pds.example.org" /etc/hosts 2>/dev/null; then 76 + echo "⚠️ WARNING: Please add these lines to your /etc/hosts file:" 77 + echo " 127.0.0.1 pds.example.org" 78 + echo " 127.0.0.1 plc.example.org" 79 + echo "" 80 + fi 81 + 82 + # Kill existing session if it exists 83 + tmux kill-session -t atproto 2>/dev/null || true 84 + 85 + echo "🚀 Starting AT Protocol services in tmux..." 86 + 87 + # Create new tmux session with PLC server 88 + tmux new-session -d -s atproto "${plc}/bin/plc" 89 + 90 + # Split horizontally for PDS server 91 + tmux split-window -h -t atproto "${pds}/bin/pds" 92 + 93 + # Split the right pane vertically for Caddy proxy 94 + tmux split-window -v -t atproto.1 "${caddy-proxy}/bin/caddy-proxy" 95 + 96 + # Split the left pane vertically for MailHog 97 + tmux split-window -v -t atproto.0 "${mailhog}/bin/mailhog" 98 + 99 + # Select the first pane 100 + tmux select-pane -t atproto.0 101 + 102 + echo "✅ Services started in tmux session 'atproto'" 103 + echo "" 104 + echo "📋 Available commands:" 105 + echo " tmux attach -t atproto - Attach to the session" 106 + echo " tmux kill-session -t atproto - Stop all services" 107 + echo "" 108 + echo "🔲 Panes layout (2x2 grid):" 109 + echo " • Top-left: PLC server" 110 + echo " • Bottom-left: MailHog server" 111 + echo " • Top-right: PDS server" 112 + echo " • Bottom-right: Caddy proxy" 113 + echo "" 114 + echo "💡 Use Ctrl+b followed by arrow keys to switch between panes" 115 + ''; 53 116 }; 54 117 55 - # Development shell 118 + # Development shell with tools (no automatic service management) 56 119 devShells.${system}.default = pkgs.mkShell { 57 120 buildInputs = with pkgs; [ 58 121 caddy ··· 62 125 openssl 63 126 mailhog 64 127 postgresql 128 + bluesky-pdsadmin 129 + goat 130 + tmux 65 131 ]; 66 132 67 133 shellHook = '' 68 - echo "Caddy development environment with Bluesky PDS" 69 - echo "Available commands:" 70 - echo " nix run .#generate-certs - Generate test certificates" 71 - echo " nix run .#caddy-proxy - Start Caddy with full config" 72 - echo " nix run .#plc - Start DID PLC server with PostgreSQL" 73 - echo " nix run .#pds - Start Bluesky PDS server" 74 - echo " nix run .#mailhog - Start MailHog email server" 134 + echo "🚀 AT Protocol Development Environment" 135 + echo "" 136 + echo "🌐 Services will be available at:" 137 + echo " • Bluesky PDS: https://pds.example.org:8443" 138 + echo " • DID PLC: https://plc.example.org:8444" 139 + echo " • MailHog: http://localhost:8025" 75 140 echo "" 76 - echo "Services:" 77 - echo " Bluesky PDS: https://pds.example.org:8443 (proxied from port 3000)" 78 - echo " DID PLC: https://plc.example.org:8444 (proxied from port 2582, PostgreSQL on 5433)" 79 - echo " MailHog: http://localhost:8025 (SMTP on port 1025)" 141 + echo "🛠️ Available tools: bluesky-pdsadmin, goat" 142 + echo "" 143 + echo "💡 Available packages:" 144 + echo " nix run .#all - Start all services in tmux (recommended)" 145 + echo " nix run .#plc - Start PLC server" 146 + echo " nix run .#pds - Start PDS server" 147 + echo " nix run .#caddy-proxy - Start Caddy proxy" 148 + echo " nix run .#mailhog - Start MailHog" 149 + echo " nix run .#generate-certs - Generate SSL certificates" 80 150 echo "" 81 - echo "Environment variables:" 82 - echo " BLUESKY_PDS_PORT=3000 - Port for Bluesky PDS (default: 3000)" 151 + echo "🚀 Quick start: nix run .#all" 152 + echo "ℹ️ Note: You control when services start and stop" 83 153 echo "" 84 - echo "Usage:" 85 - echo " 1. Add these lines to your /etc/hosts file:" 86 - echo " 127.0.0.1 pds.example.org" 87 - echo " 127.0.0.1 plc.example.org" 88 - echo " 2. Run 'nix run .#generate-certs' to create certificates" 89 - echo " 3. Run 'nix run .#mailhog' in one terminal" 90 - echo " 4. Run 'nix run .#plc' in another terminal" 91 - echo " 5. Run 'nix run .#pds' in another terminal" 92 - echo " 6. Run 'nix run .#caddy-proxy' in another terminal" 93 - echo " 7. Access services at:" 94 - echo " - Bluesky PDS: https://pds.example.org:8443" 95 - echo " - DID PLC: https://plc.example.org:8444" 96 - echo " - MailHog: http://localhost:8025" 154 + 155 + # Set custom prompt 156 + export PS1='[AT Proto Dev] \u@\h:\w\$ ' 97 157 ''; 98 158 }; 99 159 };