Subject: [PATCH 01/16] gnu: Add ocaml-jsonrpc.

From: Herman Rimm <[email-masked]>
Date: Wed, 25 Sep 2024 09:54:11 +0200

* gnu/packages/ocaml.scm (ocaml-jsonrpc): Add variable.
* gnu/packages/patches/ocaml-jsonrpc.patch: Add file.
* gnu/local.mk (dist_patch_DATA): Register file.

Change-Id: I0486038d2d5936ca462413eca605c356c00d39d7
---
 gnu/local.mk                             |  1 +
 gnu/packages/ocaml.scm                   | 42 +++++++++++++++
 gnu/packages/patches/ocaml-jsonrpc.patch | 66 ++++++++++++++++++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 gnu/packages/patches/ocaml-jsonrpc.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 795ff822a4..dc139429dd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1820,6 +1820,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/nyacc-binary-literals.patch		\
   %D%/packages/patches/obs-modules-location.patch		\
   %D%/packages/patches/ocaml-multiple-definitions.patch		\
+  %D%/packages/patches/ocaml-jsonrpc.patch			\
   %D%/packages/patches/ocaml-4.07-dynamically-allocate-signal-stack.patch	\
   %D%/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch	\
   %D%/packages/patches/ocaml-4.09-multiple-definitions.patch	\
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 6ba5f5e374..e7dcedc939 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -73,6 +73,7 @@ (define-module (gnu packages ocaml)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages networking)
   #:use-module (gnu packages node)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
@@ -81,6 +82,7 @@ (define-module (gnu packages ocaml)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages rsync)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tex)
@@ -3984,6 +3986,46 @@ (define-public ocaml-jsonm
 without a complete in-memory representation of the data.")
     (license license:isc)))
 
+(define-public ocaml-jsonrpc
+  (package
+    (name "ocaml-jsonrpc")
+    (version "1.17.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ocaml/ocaml-lsp")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (modules '((guix build utils)))
+       (snippet
+        #~(for-each delete-file-recursively
+                    '("jsonrpc-fiber"
+                      "lsp"
+                      "lsp.opam"
+                      "lsp-fiber"
+                      "ocaml-lsp-server"
+                      "ocaml-lsp-server.opam")))
+       (sha256
+        (base32
+         "1w1m2mi7va3wcwgvgzqd3af6hrhx5zzyr3hqa228pcimp44w6f0h"))
+       (patches (search-patches "ocaml-jsonrpc.patch"))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-odoc))
+    (native-inputs (list dune-stdune
+                         ocaml-dune-build-info
+                         ocaml-ppx-expect
+                         ocaml-ppx-inline-test
+                         ocaml-ppx-yojson-conv-lib
+                         ocaml-uutf
+                         ocaml-yojson))
+    (home-page "https://github.com/ocaml/ocaml-lsp")
+    (synopsis "Jsonrpc protocol implemenation")
+    (description
+      "This package provides a JSON-RPC implementation as described in
+      https://www.jsonrpc.org/specification.")
+    (license license:isc)))
+
 (define-public ocaml-ocp-indent
   (package
     (name "ocaml-ocp-indent")
diff --git a/gnu/packages/patches/ocaml-jsonrpc.patch b/gnu/packages/patches/ocaml-jsonrpc.patch
new file mode 100644
index 0000000000..1b40f4b90e
--- /dev/null
+++ b/gnu/packages/patches/ocaml-jsonrpc.patch
@@ -0,0 +1,66 @@
+diff --git a/dune-project b/dune-project
+index 34c04542..d25da5c8 100644
+--- a/dune-project
++++ b/dune-project
+@@ -1,6 +1,6 @@
+ (lang dune 3.0)
+ (using cinaps 1.0)
+-(name lsp)
++(name jsonrpc)
+ 
+ (implicit_transitive_deps false)
+ 
+@@ -22,53 +22,6 @@
+ 
+ (generate_opam_files true)
+ 
+-(package
+- (name lsp)
+- (synopsis "LSP protocol implementation in OCaml")
+- (description "
+-Implementation of the LSP protocol in OCaml. It is designed to be as portable as
+-possible and does not make any assumptions about IO.
+-")
+- (depends
+-  (jsonrpc (= :version))
+-  yojson
+-  (ppx_yojson_conv_lib (>= "v0.14"))
+-  (cinaps :with-test)
+-  (ppx_expect (and (>= v0.15.0) :with-test))
+-  (uutf (>= 1.0.2))
+-  (odoc :with-doc)
+-  (ocaml (>= 4.14))))
+-
+-(package
+- (name ocaml-lsp-server)
+- (synopsis "LSP Server for OCaml")
+- (description "An LSP server for OCaml.")
+- (depends
+-  yojson
+-  (re (>= 1.5.0))
+-  (ppx_yojson_conv_lib (>= "v0.14"))
+-  (dune-rpc (>= 3.4.0))
+-  (chrome-trace (>= 3.3.0))
+-  dyn
+-  stdune
+-  (fiber (and (>= 3.1.1) (< 4.0.0)))
+-  xdg
+-  ordering
+-  dune-build-info
+-  spawn
+-  astring
+-  camlp-streams
+-  (ppx_expect (and (>= v0.15.0) :with-test))
+-  (ocamlformat (and :with-test (= 0.24.1)))
+-  (ocamlc-loc (>= 3.7.0))
+-  (uutf (>= 1.0.2))
+-  (pp (>= 1.1.2))
+-  (csexp (>= 1.5))
+-  (ocamlformat-rpc-lib (>= 0.21.0))
+-  (odoc :with-doc)
+-  (ocaml (and (>= 4.14) (< 5.2)))
+-  (merlin-lib (and (>= 4.9) (< 5.0)))))
+-
+ (package
+  (name jsonrpc)
+  (synopsis "Jsonrpc protocol implemenation")

base-commit: 3ac69c1a757430d6dfdd37eb948ba1d6967967cc
-- 
2.45.2