Subject: [PATCH 2/3] gnu: Add ocaml-macaddr.

From: raingloom <[email-masked]>
Date: Thu, 29 Sep 2022 18:47:17 +0200

* gnu/packages/ocaml-mirage.scm
  (ipaddr-arguments) (ocaml-macaddr): New variables.
---
 gnu/packages/ocaml-mirage.scm | 38 +++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/ocaml-mirage.scm b/gnu/packages/ocaml-mirage.scm
index 67514c4932..b1389507d5 100644
--- a/gnu/packages/ocaml-mirage.scm
+++ b/gnu/packages/ocaml-mirage.scm
@@ -54,3 +54,41 @@ (define-public ocaml-domain-name
      "Parses and constructs RFC compliant domain names.  The invariants on the
 length of domain names are preserved throughout the module.")
     (license license:isc)))
+
+(define (ipaddr-arguments pkg)
+  `(#:package ,pkg
+    #:phases
+    (modify-phases %standard-phases
+      (replace 'check
+        (lambda* (#:key tests? #:allow-other-keys)
+          (when tests?
+            ;; no separate tests directory
+            (invoke "dune" "runtest" "-p" ,pkg)))))))
+
+(define-public ocaml-macaddr
+  (package
+    (name "ocaml-macaddr")
+    (version "5.3.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/mirage/ocaml-ipaddr/")
+                    (commit (string-append "v" version))))
+              (file-name name)
+              (sha256
+               (base32
+                "1zgwx0ms3l4k4dzwnkrwq4zzqjrddjsvqn66mbd0rm6aq1ib019d"))))
+    (build-system dune-build-system)
+    (arguments (ipaddr-arguments "macaddr"))
+    (propagated-inputs (list ocaml-cstruct))
+    (native-inputs (list ocaml-ounit2 ocaml-ppx-sexp-conv))
+    (home-page "https://github.com/mirage/ocaml-ipaddr")
+    (synopsis "OCaml library for manipulation of MAC address representations")
+    (description
+     "@itemize
+@item MAC-48 (Ethernet) address support
+@item `Macaddr` is a @code{Map.OrderedType}
+@item All types have sexplib serializers/deserializers optionally via the
+`Macaddr_sexp` library
+@end itemize")
+    (license license:isc)))
-- 
2.37.3