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.

wip: Add relay

+98 -17
+1
.gitignore
··· 1 1 certs 2 2 data 3 + result
+6
Caddyfile
··· 27 27 28 28 reverse_proxy localhost:2582 29 29 } 30 + 31 + relay.example.org:8445 { 32 + tls ./certs/cert.pem ./certs/key.pem 33 + 34 + reverse_proxy localhost:2470 35 + }
+8 -5
README.md
··· 8 8 ``` 9 9 127.0.0.1 pds.example.org 10 10 127.0.0.1 plc.example.org 11 + 127.0.0.1 relay.example.org 11 12 ``` 12 13 13 14 Generate SSL certificates before first use: ··· 26 27 ```bash 27 28 nix run .#all 28 29 ``` 29 - This will start all services in a 2x2 tmux pane layout: 30 - - Top-left: PLC server 31 - - Bottom-left: MailHog server 32 - - Top-right: PDS server 33 - - Bottom-right: Caddy proxy 30 + This will start all services in a single-column tmux pane layout: 31 + - Pane 0: PLC server 32 + - Pane 1: PDS server 33 + - Pane 2: Caddy proxy 34 + - Pane 3: AT Protocol Relay 34 35 35 36 3. **Create an invite code:** 36 37 ```bash ··· 76 77 77 78 - **Bluesky PDS**: https://pds.example.org:8443 78 79 - **DID PLC**: https://plc.example.org:8444 80 + - **AT Protocol Relay**: https://relay.example.org:8445 79 81 - **MailHog**: http://localhost:8025 80 82 81 83 ## Available Tools ··· 88 90 89 91 - `tmux attach -t atproto` - Attach to the services session 90 92 - `tmux kill-session -t atproto` - Stop all services 93 + - `nix run .#mailhog` - Start MailHog (run separately if needed) 91 94 - `nix run .#generate-certs` - Generate SSL certificates
+37 -12
flake.nix
··· 14 14 caddy-proxy = pkgs.callPackage ./packages/caddy.nix { }; 15 15 pds = pkgs.callPackage ./packages/pds.nix { }; 16 16 mailhog = pkgs.callPackage ./packages/mailhog.nix { }; 17 + indigo-relay = pkgs.callPackage ./packages/indigo-relay.nix { }; 17 18 in 18 19 { 19 20 packages.${system} = { ··· 25 26 pds = pds; 26 27 27 28 mailhog = mailhog; 29 + 30 + indigo-relay = indigo-relay; 28 31 29 32 # Script to generate certificates on host 30 33 generate-certs = pkgs.writeShellScriptBin "generate-certs" '' ··· 44 47 127.0.0.1 \ 45 48 ::1 \ 46 49 pds.example.org \ 47 - plc.example.org 50 + plc.example.org \ 51 + relay.example.org 48 52 49 53 echo "Certificates generated in ./certs/" 50 54 echo "Files created:" ··· 87 91 # Create new tmux session with PLC server 88 92 tmux new-session -d -s atproto "${plc}/bin/plc" 89 93 90 - # Split horizontally for PDS server 91 - tmux split-window -h -t atproto "${pds}/bin/pds" 94 + # Split vertically for PDS server 95 + tmux split-window -v -t atproto "${pds}/bin/pds" 96 + 97 + # Split vertically for Caddy proxy 98 + tmux split-window -v -t atproto "${caddy-proxy}/bin/caddy-proxy" 92 99 93 - # Split the right pane vertically for Caddy proxy 94 - tmux split-window -v -t atproto.1 "${caddy-proxy}/bin/caddy-proxy" 100 + # Split vertically for Relay (with environment variables) 101 + tmux split-window -v -t atproto "RELAY_ADMIN_PASSWORD=password RELAY_PLC_HOST=https://plc.example.org:8444 RELAY_TRUSTED_DOMAINS=*.example.org RELAY_ALLOW_INSECURE_HOSTS=true ${indigo-relay}/bin/relay serve" 95 102 96 - # Split the left pane vertically for MailHog 97 - tmux split-window -v -t atproto.0 "${mailhog}/bin/mailhog" 103 + # Make all panes equal size 104 + tmux select-layout -t atproto even-vertical 98 105 99 106 # Select the first pane 100 107 tmux select-pane -t atproto.0 ··· 105 112 echo " tmux attach -t atproto - Attach to the session" 106 113 echo " tmux kill-session -t atproto - Stop all services" 107 114 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" 115 + echo "📋 Panes layout (single column):" 116 + echo " • Pane 0: PLC server" 117 + echo " • Pane 1: PDS server" 118 + echo " • Pane 2: Caddy proxy" 119 + echo " • Pane 3: AT Protocol Relay" 113 120 echo "" 114 121 echo "💡 Use Ctrl+b followed by arrow keys to switch between panes" 122 + ''; 123 + 124 + # Script to start relay with environment 125 + relay = pkgs.writeShellScriptBin "relay" '' 126 + set -e 127 + 128 + echo "Starting AT Protocol Relay..." 129 + echo "Admin password: password" 130 + echo "PLC host: https://plc.example.org:8444" 131 + echo "" 132 + 133 + # Set relay environment variables 134 + export RELAY_ADMIN_PASSWORD="password" 135 + export RELAY_PLC_HOST="https://plc.example.org:8444" 136 + export RELAY_TRUSTED_DOMAINS="*.example.org" 137 + export RELAY_ALLOW_INSECURE_HOSTS="true" 138 + 139 + ${indigo-relay}/bin/relay serve 115 140 ''; 116 141 }; 117 142
+46
packages/indigo-relay.nix
··· 1 + { lib 2 + , buildGoModule 3 + , fetchFromGitHub 4 + }: 5 + 6 + buildGoModule rec { 7 + pname = "indigo-relay"; 8 + version = "unstable-2024-10-03"; 9 + 10 + src = fetchFromGitHub { 11 + owner = "bluesky-social"; 12 + repo = "indigo"; 13 + rev = "master"; # Latest commit from master branch 14 + hash = "sha256-yVj7DKGAUXQO4eTu4reAtm7bTE4ab0jYGX2ba74qazU="; 15 + }; 16 + 17 + vendorHash = "sha256-7mYvgvR0tZdEnUgUYzKv6d2QyeXXnrFgVwY8/4UM3oU="; 18 + 19 + # Build only the relay binary 20 + subPackages = [ "cmd/relay" ]; 21 + 22 + # Set the module path 23 + modRoot = "."; 24 + 25 + # Build configuration 26 + env.CGO_ENABLED = "1"; 27 + 28 + # Build flags 29 + ldflags = [ 30 + "-s" 31 + "-w" 32 + "-X github.com/carlmjohnson/versioninfo.Version=${version}" 33 + ]; 34 + 35 + # Tests require additional services running 36 + doCheck = false; 37 + 38 + meta = with lib; { 39 + description = "AT Protocol relay daemon from the Indigo project"; 40 + homepage = "https://github.com/bluesky-social/indigo"; 41 + license = with licenses; [ mit asl20 ]; # Dual licensed 42 + maintainers = with maintainers; [ ]; 43 + platforms = platforms.linux ++ platforms.darwin; 44 + mainProgram = "relay"; 45 + }; 46 + }