1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 stdenvNoCC, 6 7 # build system 8 poetry-core, 9 10 # dependencies 11 langgraph-checkpoint, 12 ormsgpack, 13 psycopg, 14 psycopg-pool, 15 16 # testing 17 pgvector, 18 postgresql, 19 postgresqlTestHook, 20 pytestCheckHook, 21 pytest-asyncio, 22 23 # passthru 24 nix-update-script, 25}: 26 27buildPythonPackage rec { 28 pname = "langgraph-checkpoint-postgres"; 29 version = "2.0.21"; 30 pyproject = true; 31 32 src = fetchFromGitHub { 33 owner = "langchain-ai"; 34 repo = "langgraph"; 35 tag = "checkpointpostgres==${version}"; 36 hash = "sha256-hl1EBOtUkSfHGxsM+LOZPLSvkW7hdHS08klpvA7/Bd0="; 37 }; 38 39 postgresqlTestSetupPost = '' 40 substituteInPlace tests/conftest.py \ 41 --replace-fail "DEFAULT_URI = \"postgres://postgres:postgres@localhost:5441/postgres?sslmode=disable\"" "DEFAULT_URI = \"postgres:///$PGDATABASE\"" \ 42 --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5441/\"" "DEFAULT_POSTGRES_URI = \"postgres:///\"" 43 ''; 44 45 sourceRoot = "${src.name}/libs/checkpoint-postgres"; 46 47 build-system = [ poetry-core ]; 48 49 dependencies = [ 50 langgraph-checkpoint 51 ormsgpack 52 psycopg 53 psycopg-pool 54 ]; 55 56 pythonRelaxDeps = [ 57 "langgraph-checkpoint" 58 "psycopg-pool" 59 ]; 60 61 doCheck = !(stdenvNoCC.hostPlatform.isDarwin); 62 63 nativeCheckInputs = [ 64 pytest-asyncio 65 pytestCheckHook 66 (postgresql.withPackages (p: with p; [ pgvector ])) 67 postgresqlTestHook 68 ]; 69 70 preCheck = '' 71 export postgresqlTestUserOptions="LOGIN SUPERUSER" 72 ''; 73 74 disabledTests = [ 75 # psycopg.errors.FeatureNotSupported: extension "vector" is not available 76 # /nix/store/...postgresql-and-plugins-16.4/share/postgresql/extension/vector.control": No such file or directory. 77 "test_embed_with_path" 78 "test_embed_with_path_sync" 79 "test_scores" 80 "test_search_sorting" 81 "test_vector_store_initialization" 82 "test_vector_insert_with_auto_embedding" 83 "test_vector_update_with_embedding" 84 "test_vector_search_with_filters" 85 "test_vector_search_pagination" 86 "test_vector_search_edge_cases" 87 ]; 88 89 pythonImportsCheck = [ "langgraph.checkpoint.postgres" ]; 90 91 passthru.updateScript = nix-update-script { 92 extraArgs = [ 93 "--version-regex" 94 "checkpointpostgres==(\\d+\\.\\d+\\.\\d+)" 95 ]; 96 }; 97 98 meta = { 99 description = "Library with a Postgres implementation of LangGraph checkpoint saver"; 100 homepage = "https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint-postgres"; 101 changelog = "https://github.com/langchain-ai/langgraph/releases/tag/checkpointpostgres==${src.tag}"; 102 license = lib.licenses.mit; 103 maintainers = with lib.maintainers; [ 104 drupol 105 sarahec 106 ]; 107 }; 108}