Subject: [PATCH] gnu: Add microcabal.

From: Homo <[email-masked]>
Date: Thu, 23 Jan 2025 18:20:33 +0200

Depends on <https://issues.guix.gnu.org/75778>.

* gnu/packages/haskell-apps.scm (microcabal): New variable.

Change-Id: Ib676c2afc360c379183422b1038f045af5485b59
---
 gnu/packages/haskell-apps.scm | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/gnu/packages/haskell-apps.scm b/gnu/packages/haskell-apps.scm
index 1ef3ed4035..d0c3ebdc42 100644
--- a/gnu/packages/haskell-apps.scm
+++ b/gnu/packages/haskell-apps.scm
@@ -20,6 +20,7 @@
 ;;; Copyright © 2021 Morgan Smith <[email-masked]>
 ;;; Copyright © 2022 David Thompson <[email-masked]>
 ;;; Copyright © 2024 jgart <[email-masked]>
+;;; Copyright © 2025 Homo <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu packages haskell-apps)
   #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
   #:use-module (gnu packages)
   #:use-module (gnu packages bash)
@@ -783,6 +785,54 @@ (define-public matterhorn
      "This is a terminal client for the Mattermost chat system.")
     (license license:bsd-3)))
 
+(define-public microcabal
+  ;; There are no tags, using latest commit.
+  (let ((commit "52e23c1472f63c546e8c366b722aaaef365713f9")
+        (revision "0"))
+    (package
+      (name "microcabal")
+      (version (git-version "0.4.1.0" revision commit))
+      (source (origin
+        (method git-fetch)
+        (uri (git-reference
+          (url "https://github.com/augustss/MicroCabal")
+          (commit commit)))
+        (file-name (git-file-name name version))
+        (sha256
+          (base32 "0f1ikjgj2wrg1wrc4g4rhws791iajvajk7pr8yjr4di2v9h930ak"))))
+      (build-system gnu-build-system)
+      (arguments
+        (list
+          #:make-flags #~(list "MHS=mhs")
+          ;; Tests require *.cabal files from MicroHs's code.
+          #:tests? #f
+          #:phases
+          #~(modify-phases %standard-phases
+            (replace 'configure
+              (lambda _
+                (substitute* "Makefile"
+                  (("MHSDIR=[^ ]* ?")
+                    "")
+                  ;; Don't build with GHC.
+                  (("bin/gmcabal bin/mcabal")
+                    "bin/mcabal"))))
+            (replace 'install
+              (lambda _
+                (let ((bin (string-append #$output "/bin/")))
+                  (install-file "bin/mcabal" bin)))))))
+      (propagated-inputs (list microhs))
+      (home-page "https://github.com/augustss/MicroCabal")
+      (synopsis "Reimplementation of a subset of Cabal")
+      (description "Why a reimplementation?  Because Cabal is not a Haskell tool, it is a ghc tool.
+A Haskell tool should be compilable by an implementation of Haskell2010,
+which Cabal is definitely not.
+
+The implementation assumes a Unix-like system with commands like `wget` and `tar`.
+
+To get a consistent set of packages MicroCabal uses Stackage to find compatible packages.
+So in a sense, MicroCabal is more like a MicroStackage.")
+      (license license:asl2.0))))
+
 (define-public nixfmt
   (package
     (name "nixfmt")
-- 
2.47.1