@@ -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))))