1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 poetry-core, 9 10 # dependencies 11 langchain-core, 12 langgraph-checkpoint, 13 langgraph-prebuilt, 14 langgraph-sdk, 15 xxhash, 16 17 # tests 18 aiosqlite, 19 dataclasses-json, 20 grandalf, 21 httpx, 22 langgraph-checkpoint-postgres, 23 langgraph-checkpoint-sqlite, 24 langsmith, 25 psycopg, 26 pydantic, 27 pytest-asyncio, 28 pytest-mock, 29 pytest-repeat, 30 pytest-xdist, 31 pytestCheckHook, 32 syrupy, 33 postgresql, 34 postgresqlTestHook, 35 36 # passthru 37 nix-update-script, 38}: 39buildPythonPackage rec { 40 pname = "langgraph"; 41 version = "0.4.1"; 42 pyproject = true; 43 44 src = fetchFromGitHub { 45 owner = "langchain-ai"; 46 repo = "langgraph"; 47 tag = "${version}"; 48 hash = "sha256-bTxtfduuuyRITZqhk15aWwxNwiZ7TMTgBOEPat6zVIc="; 49 }; 50 51 postgresqlTestSetupPost = '' 52 substituteInPlace tests/conftest.py \ 53 --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5442/\"" "DEFAULT_POSTGRES_URI = \"postgres:///$PGDATABASE\"" 54 ''; 55 56 sourceRoot = "${src.name}/libs/langgraph"; 57 58 build-system = [ poetry-core ]; 59 60 dependencies = [ 61 langchain-core 62 langgraph-checkpoint 63 langgraph-prebuilt 64 langgraph-sdk 65 xxhash 66 ]; 67 68 pythonImportsCheck = [ "langgraph" ]; 69 70 # postgresql doesn't play nicely with the darwin sandbox: 71 # FATAL: could not create shared memory segment: Operation not permitted 72 doCheck = !stdenv.hostPlatform.isDarwin; 73 74 nativeCheckInputs = [ 75 pytestCheckHook 76 postgresql 77 postgresqlTestHook 78 ]; 79 80 checkInputs = [ 81 aiosqlite 82 dataclasses-json 83 grandalf 84 httpx 85 langgraph-checkpoint-postgres 86 langgraph-checkpoint-sqlite 87 langsmith 88 psycopg 89 psycopg.pool 90 pydantic 91 pytest-asyncio 92 pytest-mock 93 pytest-repeat 94 pytest-xdist 95 syrupy 96 ]; 97 98 disabledTests = [ 99 # test is flaky due to pydantic error on the exception 100 "test_doesnt_warn_valid_schema" 101 "test_tool_node_inject_store" 102 103 # Disabling tests that requires to create new random databases 104 "test_cancel_graph_astream" 105 "test_cancel_graph_astream_events_v2" 106 "test_channel_values" 107 "test_fork_always_re_runs_nodes" 108 "test_interruption_without_state_updates" 109 "test_interruption_without_state_updates_async" 110 "test_invoke_two_processes_in_out_interrupt" 111 "test_nested_graph_interrupts" 112 "test_no_modifier_async" 113 "test_no_modifier" 114 "test_pending_writes_resume" 115 "test_remove_message_via_state_update" 116 117 # pydantic.errors.PydanticForbiddenQualifier, 118 # see https://github.com/langchain-ai/langgraph/issues/4360 119 "test_state_schema_optional_values" 120 ]; 121 122 disabledTestPaths = [ 123 # psycopg.errors.InsufficientPrivilege: permission denied to create database 124 "tests/test_checkpoint_migration.py" 125 "tests/test_large_cases.py" 126 "tests/test_large_cases_async.py" 127 "tests/test_pregel.py" 128 "tests/test_pregel_async.py" 129 ]; 130 131 passthru.updateScript = nix-update-script { 132 extraArgs = [ 133 "--version-regex" 134 "^(\\d+\\.\\d+\\.\\d+)" 135 ]; 136 }; 137 138 meta = { 139 description = "Build resilient language agents as graphs"; 140 homepage = "https://github.com/langchain-ai/langgraph"; 141 changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}"; 142 license = lib.licenses.mit; 143 maintainers = with lib.maintainers; [ sarahec ]; 144 }; 145}