{ lib , callPackage , python312 , stdenv , makeWrapper , hindsight-src , uv2nix , pyproject-nix , pyproject-build-systems }: # Build the hindsight-api-slim venv from upstream's uv workspace. We pick # `hindsight-api-slim` (not `hindsight-api`) so we skip the `[all]` extras # (local-ml, embedded-db). With openai-codex provider for both LLM and # embeddings, and system postgres as the store, those extras are unused weight. let workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = hindsight-src; }; overlay = workspace.mkPyprojectOverlay { sourcePreference = "wheel"; }; pythonSet = (callPackage pyproject-nix.build.packages { python = python312; }).overrideScope (lib.composeManyExtensions [ pyproject-build-systems.overlays.default overlay ]); venv = pythonSet.mkVirtualEnv "hindsight-api-env" { hindsight-api-slim = [ ]; }; in stdenv.mkDerivation { pname = "hindsight-api"; version = "0.7.2"; dontUnpack = true; nativeBuildInputs = [ makeWrapper ]; installPhase = '' runHook preInstall mkdir -p $out/bin # The venv ships hindsight-api / hindsight-worker / hindsight-admin / # hindsight-local-mcp / alembic in $venv/bin. Link them out so callers # don't have to know about the venv layout. for bin in hindsight-api hindsight-worker hindsight-admin hindsight-local-mcp alembic; do if [ -e ${venv}/bin/$bin ]; then ln -s ${venv}/bin/$bin $out/bin/$bin fi done runHook postInstall ''; passthru = { inherit venv pythonSet; pythonEnv = venv; }; meta = with lib; { description = "Hindsight: agent memory with knowledge graph and tiered retrieval"; homepage = "https://github.com/vectorize-io/hindsight"; license = licenses.mit; mainProgram = "hindsight-api"; platforms = platforms.linux; }; }