Flake to setup a local env for atproto development

Add tmux session

edouard.paris a3acc8b5 646be5bb

verified
Changed files
+87 -27
+87 -27
flake.nix
···
echo "Files created:"
ls -la .
'';
+
+
# Script to start all services in tmux
+
all = pkgs.writeShellScriptBin "all" ''
+
set -e
+
+
# Check if tmux is available
+
if ! command -v tmux >/dev/null 2>&1; then
+
echo "❌ tmux is not installed. Please install tmux first."
+
exit 1
+
fi
+
+
# Check if certificates exist
+
if [ ! -f "./certs/cert.pem" ]; then
+
echo "⚠️ WARNING: SSL certificates not found. Run 'nix run .#generate-certs' first."
+
read -p "Continue anyway? (y/N): " -n 1 -r
+
echo
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
+
exit 1
+
fi
+
fi
+
+
# Check if hosts file is configured
+
if ! grep -q "pds.example.org" /etc/hosts 2>/dev/null; then
+
echo "⚠️ WARNING: Please add these lines to your /etc/hosts file:"
+
echo " 127.0.0.1 pds.example.org"
+
echo " 127.0.0.1 plc.example.org"
+
echo ""
+
fi
+
+
# Kill existing session if it exists
+
tmux kill-session -t atproto 2>/dev/null || true
+
+
echo "🚀 Starting AT Protocol services in tmux..."
+
+
# Create new tmux session with PLC server
+
tmux new-session -d -s atproto "${plc}/bin/plc"
+
+
# Split horizontally for PDS server
+
tmux split-window -h -t atproto "${pds}/bin/pds"
+
+
# Split the right pane vertically for Caddy proxy
+
tmux split-window -v -t atproto.1 "${caddy-proxy}/bin/caddy-proxy"
+
+
# Split the left pane vertically for MailHog
+
tmux split-window -v -t atproto.0 "${mailhog}/bin/mailhog"
+
+
# Select the first pane
+
tmux select-pane -t atproto.0
+
+
echo "✅ Services started in tmux session 'atproto'"
+
echo ""
+
echo "📋 Available commands:"
+
echo " tmux attach -t atproto - Attach to the session"
+
echo " tmux kill-session -t atproto - Stop all services"
+
echo ""
+
echo "🔲 Panes layout (2x2 grid):"
+
echo " • Top-left: PLC server"
+
echo " • Bottom-left: MailHog server"
+
echo " • Top-right: PDS server"
+
echo " • Bottom-right: Caddy proxy"
+
echo ""
+
echo "💡 Use Ctrl+b followed by arrow keys to switch between panes"
+
'';
};
-
# Development shell
+
# Development shell with tools (no automatic service management)
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
caddy
···
openssl
mailhog
postgresql
+
bluesky-pdsadmin
+
goat
+
tmux
];
shellHook = ''
-
echo "Caddy development environment with Bluesky PDS"
-
echo "Available commands:"
-
echo " nix run .#generate-certs - Generate test certificates"
-
echo " nix run .#caddy-proxy - Start Caddy with full config"
-
echo " nix run .#plc - Start DID PLC server with PostgreSQL"
-
echo " nix run .#pds - Start Bluesky PDS server"
-
echo " nix run .#mailhog - Start MailHog email server"
+
echo "🚀 AT Protocol Development Environment"
+
echo ""
+
echo "🌐 Services will be available at:"
+
echo " • Bluesky PDS: https://pds.example.org:8443"
+
echo " • DID PLC: https://plc.example.org:8444"
+
echo " • MailHog: http://localhost:8025"
echo ""
-
echo "Services:"
-
echo " Bluesky PDS: https://pds.example.org:8443 (proxied from port 3000)"
-
echo " DID PLC: https://plc.example.org:8444 (proxied from port 2582, PostgreSQL on 5433)"
-
echo " MailHog: http://localhost:8025 (SMTP on port 1025)"
+
echo "🛠️ Available tools: bluesky-pdsadmin, goat"
+
echo ""
+
echo "💡 Available packages:"
+
echo " nix run .#all - Start all services in tmux (recommended)"
+
echo " nix run .#plc - Start PLC server"
+
echo " nix run .#pds - Start PDS server"
+
echo " nix run .#caddy-proxy - Start Caddy proxy"
+
echo " nix run .#mailhog - Start MailHog"
+
echo " nix run .#generate-certs - Generate SSL certificates"
echo ""
-
echo "Environment variables:"
-
echo " BLUESKY_PDS_PORT=3000 - Port for Bluesky PDS (default: 3000)"
+
echo "🚀 Quick start: nix run .#all"
+
echo "ℹ️ Note: You control when services start and stop"
echo ""
-
echo "Usage:"
-
echo " 1. Add these lines to your /etc/hosts file:"
-
echo " 127.0.0.1 pds.example.org"
-
echo " 127.0.0.1 plc.example.org"
-
echo " 2. Run 'nix run .#generate-certs' to create certificates"
-
echo " 3. Run 'nix run .#mailhog' in one terminal"
-
echo " 4. Run 'nix run .#plc' in another terminal"
-
echo " 5. Run 'nix run .#pds' in another terminal"
-
echo " 6. Run 'nix run .#caddy-proxy' in another terminal"
-
echo " 7. Access services at:"
-
echo " - Bluesky PDS: https://pds.example.org:8443"
-
echo " - DID PLC: https://plc.example.org:8444"
-
echo " - MailHog: http://localhost:8025"
+
+
# Set custom prompt
+
export PS1='[AT Proto Dev] \u@\h:\w\$ '
'';
};
};