Create NixOS module for mem0 service (Postgres + pgvector + FastAPI + nginx) #44

Closed
opened 2026-07-02 07:22:35 +01:00 by nimmo · 0 comments
Owner

Scope

Create modules/services/mem0.nix in nixos-config that consumes the mem0-nix flake input and runs the mem0 self-hosted server as native NixOS services — no Docker.

Deliverables

  • modules/services/mem0.nix with nixosConfig.mem0 options:
    • enable, stateDir, listenAddress, apiPort, dashboardPort
    • llm.provider, llm.model, llm.baseUrl, llm.apiKeySecret
    • embedder.provider, embedder.model, embedder.baseUrl
    • postgres.* (host, port, db, user, collection name)
    • dashboardDomain (for nginx vhost)
  • systemd.services.mem0-server running uvicorn with env from SOPS template
  • systemd.services.mem0-dashboard or nginx vhost serving the static Next.js export
  • Postgres + pgvector extension (NixOS services.postgresql with pgvector extension)
  • Qdrant vector store (services.qdrant) if needed by mem0 config (or rely on pgvector)
  • Alembic migrations run as a preStart or ExecStartPre hook
  • secrets/mem0.yaml skeleton (API key, JWT secret, Postgres password, LLM API key)
  • SOPS templates wired to systemd env
  • Firewall rules: bind to Nebula overlay IP only (like librarry)
  • backrest.extraPaths includes stateDir
  • serviceFailureMonitor includes mem0-server

Architecture

nginx (dashboard) → mem0-dashboard static files
                   → /api/ proxied to mem0-server (uvicorn, port 8888)
                        ↓
                   Postgres + pgvector (local)

Reference

Mirror the modules/services/librarry.nix structure:

  • SOPS secrets from secrets/mem0.yaml (not the monolithic secrets/secrets.yaml)
  • sops.templates."mem0-env" for env composition
  • systemd service with EnvironmentFile
  • nginx vhost on Nebula IP, not LAN/0.0.0.0
## Scope Create `modules/services/mem0.nix` in nixos-config that consumes the `mem0-nix` flake input and runs the mem0 self-hosted server as native NixOS services — **no Docker**. ### Deliverables - [ ] `modules/services/mem0.nix` with `nixosConfig.mem0` options: - `enable`, `stateDir`, `listenAddress`, `apiPort`, `dashboardPort` - `llm.provider`, `llm.model`, `llm.baseUrl`, `llm.apiKeySecret` - `embedder.provider`, `embedder.model`, `embedder.baseUrl` - `postgres.*` (host, port, db, user, collection name) - `dashboardDomain` (for nginx vhost) - [ ] `systemd.services.mem0-server` running uvicorn with env from SOPS template - [ ] `systemd.services.mem0-dashboard` or nginx vhost serving the static Next.js export - [ ] Postgres + pgvector extension (NixOS `services.postgresql` with `pgvector` extension) - [ ] Qdrant vector store (`services.qdrant`) if needed by mem0 config (or rely on pgvector) - [ ] Alembic migrations run as a `preStart` or `ExecStartPre` hook - [ ] `secrets/mem0.yaml` skeleton (API key, JWT secret, Postgres password, LLM API key) - [ ] SOPS templates wired to systemd env - [ ] Firewall rules: bind to Nebula overlay IP only (like librarry) - [ ] `backrest.extraPaths` includes `stateDir` - [ ] `serviceFailureMonitor` includes `mem0-server` ### Architecture ``` nginx (dashboard) → mem0-dashboard static files → /api/ proxied to mem0-server (uvicorn, port 8888) ↓ Postgres + pgvector (local) ``` ### Reference Mirror the `modules/services/librarry.nix` structure: - SOPS secrets from `secrets/mem0.yaml` (not the monolithic `secrets/secrets.yaml`) - `sops.templates."mem0-env"` for env composition - systemd service with `EnvironmentFile` - nginx vhost on Nebula IP, not LAN/0.0.0.0
nimmo closed this issue 2026-07-11 12:31:39 +01:00
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config#44
No description provided.