···
54
+
# Script to start all services in tmux
55
+
all = pkgs.writeShellScriptBin "all" ''
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."
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
69
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
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"
82
+
# Kill existing session if it exists
83
+
tmux kill-session -t atproto 2>/dev/null || true
85
+
echo "🚀 Starting AT Protocol services in tmux..."
87
+
# Create new tmux session with PLC server
88
+
tmux new-session -d -s atproto "${plc}/bin/plc"
90
+
# Split horizontally for PDS server
91
+
tmux split-window -h -t atproto "${pds}/bin/pds"
93
+
# Split the right pane vertically for Caddy proxy
94
+
tmux split-window -v -t atproto.1 "${caddy-proxy}/bin/caddy-proxy"
96
+
# Split the left pane vertically for MailHog
97
+
tmux split-window -v -t atproto.0 "${mailhog}/bin/mailhog"
99
+
# Select the first pane
100
+
tmux select-pane -t atproto.0
102
+
echo "✅ Services started in tmux session 'atproto'"
104
+
echo "📋 Available commands:"
105
+
echo " tmux attach -t atproto - Attach to the session"
106
+
echo " tmux kill-session -t atproto - Stop all services"
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"
114
+
echo "💡 Use Ctrl+b followed by arrow keys to switch between panes"
118
+
# Development shell with tools (no automatic service management)
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
···
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"
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"
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"
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"
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"
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"
155
+
# Set custom prompt
156
+
export PS1='[AT Proto Dev] \u@\h:\w\$ '