{ pkgs, ... }: { languages.javascript = { enable = true; corepack.enable = true; }; packages = [ pkgs.turbo pkgs.nginx ]; # PostgreSQL is enabled by default for development. # To use SQLite instead, create devenv.local.nix with: # { ... }: { services.postgres.enable = false; } # Then set DATABASE_URL=file:./data/atbb.db in your .env file. services.postgres = { enable = pkgs.lib.mkDefault true; package = pkgs.postgresql_17; listen_addresses = "127.0.0.1"; port = 5432; initialDatabases = [ { name = "atbb"; } ]; initialScript = '' CREATE USER atbb WITH PASSWORD 'atbb'; GRANT ALL PRIVILEGES ON DATABASE atbb TO atbb; ALTER DATABASE atbb OWNER TO atbb; ''; }; processes = let # Inline nginx config using Nix store paths so it works in the Nix # environment (no /etc/nginx/mime.types). Mirrors production nginx.conf # but listens on port 8080 (no root required) and uses a tmp working dir. nginxConf = pkgs.writeText "atbb-nginx-dev.conf" '' pid /tmp/atbb-nginx-dev.pid; error_log /dev/stderr; events { worker_connections 1024; } http { include ${pkgs.nginx}/conf/mime.types; default_type application/octet-stream; access_log /dev/stdout; client_max_body_size 10M; proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; server { listen 8080; # OAuth client metadata → appview # AT Protocol fetches {client_id}/.well-known/oauth-client-metadata # to validate the OAuth client. OAUTH_PUBLIC_URL should be set to # http://localhost:8080 so this route serves the correct document. location /.well-known/ { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # API routes → appview location /api/ { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Web UI → web location / { proxy_pass http://localhost:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } } ''; in { appview.exec = "pnpm --filter @atbb/appview dev"; web.exec = "pnpm --filter @atbb/web dev"; nginx.exec = "${pkgs.nginx}/bin/nginx -c ${nginxConf} -p /tmp/atbb-nginx-dev -g 'daemon off;'"; }; }