Subject: [PATCH 2/2] gnu: Add miking.

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 17 Jun 2023 19:08:08 +0200

* gnu/packages/miking.scm (miking): New variable.
---
 gnu/packages/miking.scm | 52 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/miking.scm b/gnu/packages/miking.scm
index 7d65e98970..83a431d443 100644
--- a/gnu/packages/miking.scm
+++ b/gnu/packages/miking.scm
@@ -73,3 +73,55 @@ (define-public miking-boot
      (description "@acronym{Miking, Meta Viking} is a meta language system
 for creating embedded domain-specific and general-purpose languages.")
      (license license:expat))))
+
+(define-public miking
+  (package/inherit
+   miking-boot
+   (name "miking")
+   (build-system copy-build-system)
+   (arguments
+    (list #:install-plan #~`(("build/mi" "bin/")
+                             ("stdlib" "lib/mcore"))
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-before 'install 'build
+                (lambda _
+                  (invoke "boot" "eval" "src/main/mi-lite.mc"
+                          "--"
+                          "0" "src/main/mi-lite.mc" "mi-lite")
+                  (invoke "./mi-lite" "1" "src/main/mi.mc" "./mi")
+                  (invoke "./mi" "compile" "src/main/mi.mc")
+                  (mkdir "build")
+                  (rename-file "mi" "build/mi")))
+              (add-after 'build 'check
+                (lambda* (#:key tests? #:allow-other-keys)
+                  (when tests?
+                    (for-each (compose
+                               (lambda (file check)
+                                 (invoke "make" "-f" file check))
+                               (lambda (pair) (values (car pair) (cdr pair))))
+                              '(("test-compile.mk" . "selected")
+                                ("test-run.mk" . "selected")
+                                ("test-tune.mk" . "all"))))))
+              (add-after 'install 'wrap
+                (lambda* (#:key inputs outputs #:allow-other-keys)
+                  (wrap-program (string-append (assoc-ref outputs "out")
+                                               "/bin/mi")
+                     `("PATH" suffix
+                       (,(dirname (search-input-file inputs "bin/dune"))
+                        ,(dirname (search-input-file inputs "bin/ocaml"))
+                        ,(dirname (search-input-file inputs "bin/which"))))
+                     `("OCAMLPATH" suffix (,(getenv "OCAMLPATH")))))))))
+   (inputs (list bash-minimal
+                 dune
+                 miking-boot
+                 ocaml
+                 ocaml-linenoise
+                 which))
+   (native-inputs (list dune
+                        gnu-make
+                        miking-boot
+                        ocaml
+                        ;; needed for tests
+                        coreutils
+                        which))))
-- 
2.40.1