diff --git a/packages/nextcloud-mcp-server/package.nix b/packages/nextcloud-mcp-server/package.nix index 3a29c9f..c776487 100644 --- a/packages/nextcloud-mcp-server/package.nix +++ b/packages/nextcloud-mcp-server/package.nix @@ -1,13 +1,124 @@ { lib, - stdenv, + python3Packages, fetchFromGitHub, - makeWrapper, -}: + fetchPypi, +}: -stdenv.mkDerivation rec { +let + fetchWheel = { pname, version, hash, propagatedBuildInputs ? [ ], meta ? { } }: + python3Packages.buildPythonPackage { + inherit pname version; + format = "wheel"; + src = fetchPypi { + inherit pname version hash; + format = "wheel"; + }; + inherit propagatedBuildInputs; + doCheck = false; + inherit meta; + }; + + pythonvcard4 = fetchWheel { + pname = "pythonvcard4"; version = "0.2.0"; hash = lib.fakeHash; + meta = with lib; { description = "vCard parsing library"; homepage = "https://github.com/GNOME/python-vcard4"; license = licenses.gpl3Plus; }; + }; + prometheus-client = fetchWheel { + pname = "prometheus_client"; version = "0.25.0"; hash = lib.fakeHash; + meta = with lib; { description = "Prometheus client"; homepage = "https://github.com/prometheus/client_python"; license = licenses.asl20; }; + }; + python-json-logger = fetchWheel { + pname = "python-json-logger"; version = "4.1.0"; hash = lib.fakeHash; + meta = with lib; { description = "JSON logger"; homepage = "https://github.com/nhairs/python-json-logger"; license = licenses.bsd2; }; + }; + importlib-metadata = fetchWheel { + pname = "importlib_metadata"; version = "8.7.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ zipp ]; + meta = with lib; { description = "Importlib metadata"; homepage = "https://github.com/python/importlib_metadata"; license = licenses.asl20; }; + }; + googleapis-common-protos = fetchWheel { + pname = "googleapis-common-protos"; version = "1.75.0"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ protobuf ]; + meta = with lib; { description = "Common protos"; homepage = "https://github.com/googleapis/python-api-common-protos"; license = licenses.asl20; }; + }; + opentelemetry-api = fetchWheel { + pname = "opentelemetry-api"; version = "1.39.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ deprecated ]; + meta = with lib; { description = "OpenTelemetry API"; homepage = "https://github.com/open-telemetry/opentelemetry-python"; license = licenses.asl20; }; + }; + opentelemetry-proto = fetchWheel { + pname = "opentelemetry-proto"; version = "1.39.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ protobuf ]; + meta = with lib; { description = "OpenTelemetry Proto"; homepage = "https://github.com/open-telemetry/opentelemetry-python"; license = licenses.asl20; }; + }; + opentelemetry-semantic-conventions = fetchWheel { + pname = "opentelemetry-semantic-conventions"; version = "0.60b1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ deprecated ]; + meta = with lib; { description = "OpenTelemetry semconv"; homepage = "https://github.com/open-telemetry/semantic-conventions"; license = licenses.asl20; }; + }; + opentelemetry-sdk = fetchWheel { + pname = "opentelemetry-sdk"; version = "1.39.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ typing-extensions ]; + meta = with lib; { description = "OpenTelemetry SDK"; homepage = "https://github.com/open-telemetry/opentelemetry-python"; license = licenses.asl20; }; + }; + x-wr-timezone = fetchWheel { + pname = "x_wr_timezone"; version = "2.0.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ icalendar click ]; + meta = with lib; { description = "X-WR-TIMEZONE"; homepage = "https://github.com/niccokunzmann/x-wr-timezone"; license = licenses.lgpl3Plus; }; + }; + opentelemetry-util-http = fetchWheel { + pname = "opentelemetry-util-http"; version = "0.60b1"; hash = lib.fakeHash; + meta = with lib; { description = "OTel HTTP utils"; homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib"; license = licenses.asl20; }; + }; + opentelemetry-exporter-otlp-proto-common = fetchWheel { + pname = "opentelemetry-exporter-otlp-proto-common"; version = "1.39.1"; hash = lib.fakeHash; + meta = with lib; { description = "OTLP proto common"; homepage = "https://github.com/open-telemetry/opentelemetry-python"; license = licenses.asl20; }; + }; + opentelemetry-instrumentation = fetchWheel { + pname = "opentelemetry-instrumentation"; version = "0.60b1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ wrapt packaging ]; + meta = with lib; { description = "OTel instrumentation"; homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib"; license = licenses.asl20; }; + }; + recurring-ical-events = fetchWheel { + pname = "recurring-ical-events"; version = "3.8.2"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ icalendar python-dateutil ]; + meta = with lib; { description = "Recurring iCal events"; homepage = "https://github.com/niccokunzmann/python-recurring-ical-events"; license = licenses.lgpl3Plus; }; + }; + opentelemetry-exporter-otlp-proto-grpc = fetchWheel { + pname = "opentelemetry-exporter-otlp-proto-grpc"; version = "1.39.1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ grpcio deprecated ]; + meta = with lib; { description = "OTLP gRPC exporter"; homepage = "https://github.com/open-telemetry/opentelemetry-python"; license = licenses.asl20; }; + }; + qdrant-client = fetchWheel { + pname = "qdrant-client"; version = "1.18.0"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ grpcio httpx numpy portalocker protobuf pydantic urllib3 ]; + meta = with lib; { description = "Qdrant client"; homepage = "https://github.com/qdrant/qdrant-client"; license = licenses.asl20; }; + }; + opentelemetry-instrumentation-asgi = fetchWheel { + pname = "opentelemetry-instrumentation-asgi"; version = "0.60b1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ asgiref ]; + meta = with lib; { description = "OTel ASGI"; homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib"; license = licenses.asl20; }; + }; + opentelemetry-instrumentation-httpx = fetchWheel { + pname = "opentelemetry-instrumentation-httpx"; version = "0.60b1"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ httpx wrapt ]; + meta = with lib; { description = "OTel HTTPX"; homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib"; license = licenses.asl20; }; + }; + opentelemetry-instrumentation-logging = fetchWheel { + pname = "opentelemetry-instrumentation-logging"; version = "0.60b1"; hash = lib.fakeHash; + meta = with lib; { description = "OTel logging"; homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib"; license = licenses.asl20; }; + }; + langchain-text-splitters = fetchWheel { + pname = "langchain-text-splitters"; version = "1.1.2"; hash = lib.fakeHash; + propagatedBuildInputs = with python3Packages; [ langchain-core ]; + meta = with lib; { description = "LangChain text splitters"; homepage = "https://github.com/langchain-ai/langchain"; license = licenses.mit; }; + }; + +in +python3Packages.buildPythonApplication rec { pname = "nextcloud-mcp-server"; version = "0.89.0"; + pyproject = true; src = fetchFromGitHub { owner = "cbcoutinho"; @@ -16,28 +127,45 @@ stdenv.mkDerivation rec { hash = "sha256-IDTSGsHQ8cCFvgSO7pDbSSHVNV0OIjjoEN9ZfkaPAvk="; }; - nativeBuildInputs = [ makeWrapper ]; + build-system = [ python3Packages.hatchling ]; - dontBuild = true; + dependencies = with python3Packages; [ + mcp httpx pillow icalendar pydantic click caldav pyjwt + aiosqlite alembic authlib fastembed anthropic boto3 starlette + jinja2 markdownify pymupdf pymupdf4llm openai dynaconf mistralai sqlalchemy - installPhase = '' - runHook preInstall - mkdir -p $out/bin $out/lib/${pname} + pythonvcard4 prometheus-client python-json-logger importlib-metadata + googleapis-common-protos opentelemetry-api opentelemetry-proto + opentelemetry-semantic-conventions opentelemetry-sdk + x-wr-timezone opentelemetry-util-http opentelemetry-exporter-otlp-proto-common + opentelemetry-instrumentation recurring-ical-events + opentelemetry-exporter-otlp-proto-grpc qdrant-client + opentelemetry-instrumentation-asgi opentelemetry-instrumentation-httpx + opentelemetry-instrumentation-logging langchain-text-splitters + ]; - # Copy the server code from source - cp -r nextcloud_mcp_server $out/lib/${pname}/ - - # The hermes-agent service already has a working venv with all deps - # Use that Python interpreter (it has PYTHONPATH set by the service env) - makeWrapper /var/lib/hermes/.local/share/nextcloud-venv/bin/python $out/bin/${pname} \ - --add-flags "-m nextcloud_mcp_server.cli" \ - --set PYTHONPATH "$out/lib/${pname}" - - runHook postInstall + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail '"prometheus-client>=0.21.0"' '"prometheus-client"' \ + --replace-fail '"mcp>=1.27,<1.28"' '"mcp"' \ + --replace-fail '"mcp[cli]>=1.27,<1.28"' '"mcp"' \ + --replace-fail '"pymupdf4llm>=0.2.2"' '"pymupdf4llm"' \ + --replace-fail '"pymupdf>=1.26.6"' '"pymupdf"' \ + --replace-fail '"qdrant-client>=1.17.0"' '"qdrant-client"' \ + --replace-fail '"opentelemetry-api>=1.28.2"' '"opentelemetry-api"' \ + --replace-fail '"opentelemetry-sdk>=1.28.2"' '"opentelemetry-sdk"' \ + --replace-fail '"opentelemetry-instrumentation-asgi>=0.49b2"' '"opentelemetry-instrumentation-asgi"' \ + --replace-fail '"opentelemetry-instrumentation-httpx>=0.49b2"' '"opentelemetry-instrumentation-httpx"' \ + --replace-fail '"opentelemetry-instrumentation-logging>=0.49b2"' '"opentelemetry-instrumentation-logging"' \ + --replace-fail '"opentelemetry-exporter-otlp-proto-grpc>=1.28.2"' '"opentelemetry-exporter-otlp-proto-grpc"' \ + --replace-fail '"python-json-logger>=3.2.0"' '"python-json-logger"' \ + --replace-fail '"pythonvcard4>=0.2.0"' '"pythonvcard4"' ''; + doCheck = false; + meta = with lib; { - description = "MCP server for Nextcloud — files (WebDAV), calendar (CalDAV), contacts (CardDAV), notes, deck, talk, and sharing"; + description = "MCP server for Nextcloud — files, calendar, contacts, notes, deck, talk, sharing"; homepage = "https://github.com/cbcoutinho/nextcloud-mcp-server"; license = licenses.agpl3Only; mainProgram = "nextcloud-mcp-server";