Subject: [bug#73466] [PATCH v2 11/15] gnu: Add ocaml-cpu.

From: Herman Rimm <[email-masked]>
Date: Thu, 26 Sep 2024 09:23:41 +0200

* gnu/packages/ocaml.scm (ocaml-cpu): Add variable.

Change-Id: Id7e0251a97b03fcd186637f1d6c6be17b11d96f8
---
 gnu/packages/ocaml.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index bf723e9055..396a546213 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -5142,6 +5142,47 @@ (define-public ocaml-cppo
 @end enumerate")
     (license license:bsd-3)))
 
+(define-public ocaml-cpu
+  (package
+    (name "ocaml-cpu")
+    (version "2.0.0")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://github.com/UnixJunkie/cpu")
+               (commit (string-append "v" version))))
+        (sha256
+          (base32
+            "1vir6gh1bhvxgj2fcn69c38yhw3jgk7dyikmw789m5ld2csnyjiv"))))
+    (build-system ocaml-build-system)
+    (arguments
+      (list #:tests? #f ; There is no test target.
+            #:phases
+            #~(modify-phases %standard-phases
+                (add-before 'configure 'create-header
+                  (lambda _
+                    (invoke "autoheader")))
+                (add-before 'configure 'fix-/bin/sh
+                  (lambda _
+                    (substitute* "configure"
+                      (("-/bin/sh") (string-append "-" (which "sh"))))))
+                (replace 'install
+                  (lambda* (#:key outputs #:allow-other-keys)
+                    (let* ((out (assoc-ref outputs "out"))
+                           (libdir
+                             (string-append out "/lib/ocaml/site-lib")))
+                      (invoke "dune" "install" "--prefix" out "--libdir"
+                              libdir)))))))
+    (native-inputs (list autoconf dune ocaml))
+    (home-page "https://github.com/UnixJunkie/cpu")
+    (synopsis "Pin current process to given core")
+    (description
+      "The module installed is called Cpu in order to not conflict with
+the Setcore module that is installed by parmap.  This library can also
+get the number of CPU cores online.")
+    (license license:bsd-3)))
+
 (define-public ocaml-seq
   (package
     (name "ocaml-seq")
-- 
2.45.2