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 14 # tests 15 langgraph-checkpoint-postgres, 16 langgraph-checkpoint-sqlite, 17 postgresql, 18 postgresqlTestHook, 19 psycopg, 20 psycopg-pool, 21 pytest-asyncio, 22 pytest-mock, 23 pytestCheckHook, 24 xxhash, 25 26 # passthru 27 nix-update-script, 28}: 29# langgraph-prebuilt isn't meant to be a standalone package but is bundled into langgraph at build time. 30# It exists so the langgraph team can iterate on it without having to rebuild langgraph. 31buildPythonPackage rec { 32 pname = "langgraph-prebuilt"; 33 version = "0.1.8"; 34 pyproject = true; 35 36 src = fetchFromGitHub { 37 owner = "langchain-ai"; 38 repo = "langgraph"; 39 tag = "prebuilt==${version}"; 40 hash = "sha256-mYcj7HRbB5H6G0CVLOICKgdtR5Wlv9WeTIBjQJqlhOE="; 41 }; 42 43 sourceRoot = "${src.name}/libs/prebuilt"; 44 45 build-system = [ poetry-core ]; 46 47 dependencies = [ 48 langchain-core 49 langgraph-checkpoint 50 ]; 51 52 skipPythonImportsCheck = true; # This will be packaged with langgraph 53 54 # postgresql doesn't play nicely with the darwin sandbox: 55 # FATAL: could not create shared memory segment: Operation not permitted 56 doCheck = !stdenv.hostPlatform.isDarwin; 57 58 nativeCheckInputs = [ 59 langgraph-checkpoint 60 langgraph-checkpoint-postgres 61 langgraph-checkpoint-sqlite 62 postgresql 63 postgresqlTestHook 64 psycopg 65 psycopg-pool 66 pytest-asyncio 67 pytest-mock 68 pytestCheckHook 69 xxhash 70 ]; 71 72 preCheck = '' 73 export PYTHONPATH=${src}/libs/langgraph:$PYTHONPATH 74 ''; 75 76 pytestFlagsArray = [ 77 "-W" 78 "ignore::pytest.PytestDeprecationWarning" 79 "-W" 80 "ignore::DeprecationWarning" 81 ]; 82 83 disabledTestPaths = [ 84 # psycopg.OperationalError: connection failed: connection to server at "127.0.0.1", port 5442 failed: Connection refused 85 # Is the server running on that host and accepting TCP/IP connections? 86 "tests/test_react_agent.py" 87 ]; 88 89 passthru.updateScript = nix-update-script { 90 extraArgs = [ 91 "--version-regex" 92 "prebuilt==(\\d+\\.\\d+\\.\\d+)" 93 ]; 94 }; 95 96 meta = { 97 description = "Prebuilt agents add-on for Langgraph. Should always be bundled with langgraph"; 98 homepage = "https://github.com/langchain-ai/langgraph"; 99 changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}"; 100 license = lib.licenses.mit; 101 maintainers = with lib.maintainers; [ sarahec ]; 102 }; 103}