This repo is a minimal, CI-proven example of:
- a reproducible dev environment (Nix flake devShell), and
- a reproducible deployable artifact (
gateway) that runs a FastAPI/Uvicorn service.
The point: one repo → same tools, same build, same runnable artifact, locally and in CI.
- Nix flake
devShells.default: pinned toolchain for development (Python +uv+ruff+ Node, etc.)packages.gateway+apps.gateway: lets both work:nix build .#gateway→ produces a runnable artifactnix run .#gateway→ runs it directly
- Gateway service
- FastAPI/Uvicorn app
- Endpoints:
GET /healthGET /v1/modelsPOST /v1/chat/completions
- Adds request-id + backend metadata (useful for debugging and for validating backend selection)
- CI (Linux runner)
- Installs Nix
- Builds the package
- Starts the gateway
- Waits for
/health - Runs a tiny smoke test
- Prints logs if startup fails (so debugging isn’t random)
nix developIf you use direnv, run once:
direnv allownix run .#gatewayDefault port is 8000. Override with:
PORT=9000 nix run .#gatewaycurl -sS localhost:${PORT:-8000}/health
curl -sS localhost:${PORT:-8000}/v1/modelsnix build .#gateway
./result/bin/gatewayLocal state is ignored so your working tree stays clean:
.direnv/result/(Nix build output symlink)
nix develop
direnv allow # once, if using direnv
nix run .#gateway
nix build .#gateway
nix flake check- Package the Python code properly
- Add
pyproject.toml - Make
src/lio_gateway/...an installable package - Update the Nix artifact so it runs without
PYTHONPATHhacks
- Add
- Add a tiny config layer
- File config (YAML/JSON) + env overrides
- CI smoke test sets
LIO_BACKENDand checks/backendand/v1/models
- Add one fast test
pytestusing FastAPITestClient(no network, fast)- Wire into
nix flake check
- Build an OCI container image via Nix
- CI builds the image, runs it, hits
/health
Move this exact pattern into the main LIO repo:
- flake/devShell/direnv
- CI smoke tests
- gateway packaging + config + backend selection hooks
- This repo is intentionally small. The goal is a clean reproducible baseline you can reuse elsewhere.
- If CI fails, check the Actions logs; the workflow prints gateway logs on startup failures.