{ lib, stdenv, fetchFromGitHub, makeWrapper, }: stdenv.mkDerivation rec { pname = "nextcloud-mcp-server"; version = "0.89.0"; src = fetchFromGitHub { owner = "cbcoutinho"; repo = "nextcloud-mcp-server"; rev = "v${version}"; hash = "sha256-IDTSGsHQ8cCFvgSO7pDbSSHVNV0OIjjoEN9ZfkaPAvk="; }; nativeBuildInputs = [ makeWrapper ]; dontBuild = true; installPhase = '' runHook preInstall mkdir -p $out/bin $out/lib/${pname} # Copy the server code from source cp -r src/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 ''; meta = with lib; { description = "MCP server for Nextcloud — files (WebDAV), calendar (CalDAV), contacts (CardDAV), notes, deck, talk, and sharing"; homepage = "https://github.com/cbcoutinho/nextcloud-mcp-server"; license = licenses.agpl3Only; mainProgram = "nextcloud-mcp-server"; platforms = platforms.all; }; }