[PATCH] gnu: Add microcabal.

  • Open
  • quality assurance status badge
Details
2 participants
  • Homo
  • Lars-Dominik Braun
Owner
unassigned
Submitted by
Homo
Severity
normal
H
(name . Homo)(address . gay@disroot.org)
20250123162034.16946-1-gay@disroot.org

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

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

Toggle diff (77 lines)
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 <Morgan.J.Smith@outlook.com>
;;; Copyright © 2022 David Thompson <dthompson2@worcester.edu>
;;; Copyright © 2024 jgart <jgart@dismail.de>
+;;; Copyright © 2025 Homo <gay@disroot.org>
;;;
;;; 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
L
L
Lars-Dominik Braun wrote 4 days ago
(name . Homo)(address . gay@disroot.org)
Z54faHshABAVLBBX@noor.fritz.box
Hi,

Toggle quote (2 lines)
> * gnu/packages/haskell-apps.scm (microcabal): New variable.

I’m using a slightly modified patch (see attachment), but `mcabal`
cannot build any packages. It seems that it ignores the MHSDIR environment
variable:

mcabal build fail
mcabal: Build package fail
mcabal: Building in /home/lars/.mcabal/packages/fail-4.9.0.0
mcabal: Building library fail
mhs: error: no location: Module not found: Mhs.Builtin
search path=[".","dist-mcabal/autogen"]
package path=["."]
mhs: error: callCommand: failed 256, "mhs -Pfail-4.9.0.0 -ofail-4.9.0.0.pkg -i -i. -idist-mcabal/autogen '-DVERSION_base=\"4.19.1.0\"' '-DMIN_VERSION_base(x,y,z)=((x)<4||(x)==4&&(y)<19||(x)==4&&(y)==19&&(z)<=1)' -a. Control.Monad.Fail"

Looking at the MicroCabal sources mcabal might be expecting mhs to be
installed as an “mcabal package”?

Lars
From 9d701dac7c56db1e662e2930a324bd4581e7ce79 Mon Sep 17 00:00:00 2001
Message-ID: <9d701dac7c56db1e662e2930a324bd4581e7ce79.1738415691.git.lars@6xq.net>
From: Homo <gay@disroot.org>
Date: Thu, 23 Jan 2025 18:20:33 +0200
Subject: [PATCH] gnu: Add microcabal.


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

Change-Id: Ib676c2afc360c379183422b1038f045af5485b59
Signed-off-by: Lars-Dominik Braun <lars@6xq.net>
---
gnu/packages/haskell-apps.scm | 59 +++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)

Toggle diff (98 lines)
diff --git a/gnu/packages/haskell-apps.scm b/gnu/packages/haskell-apps.scm
index 1ef3ed4035..6b61ae026b 100644
--- a/gnu/packages/haskell-apps.scm
+++ b/gnu/packages/haskell-apps.scm
@@ -20,6 +20,7 @@
;;; Copyright � 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright � 2022 David Thompson <dthompson2@worcester.edu>
;;; Copyright � 2024 jgart <jgart@dismail.de>
+;;; Copyright � 2025 Homo <gay@disroot.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -42,8 +43,10 @@ (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 base)
#:use-module (gnu packages bash)
#:use-module (gnu packages curl)
#:use-module (gnu packages freedesktop)
@@ -59,6 +62,7 @@ (define-module (gnu packages haskell-apps)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages rsync)
#:use-module (gnu packages version-control)
+ #:use-module (gnu packages wget)
#:use-module (gnu packages xorg))
(define-public apply-refact
@@ -783,6 +787,61 @@ (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 "75aab2f5dfa3bacc1876dc1da9828a7e54e01d68")
+ (revision "0"))
+ (package
+ (name "microcabal")
+ (version (git-version "0.5.0.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 "0hzp2zfvldl5gmnvr33vxbpd75fhm4kkdsvakd49wdpmcamp01yg"))))
+ (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
+ (add-after 'unpack 'fix-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "src/MicroCabal/Unix.hs"
+ (("(\"[^\"]*)(wget|mkdir|tar|rm|cp)( [^\"]*\")" all prefix binary postfix)
+ (string-append
+ prefix
+ (search-input-file inputs (string-append "/bin/" binary))
+ postfix)))))
+ (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)))))))
+ (inputs (list wget tar coreutils))
+ (propagated-inputs (list microhs)) ;; Propagate microhs, because it needs a search path.
+ (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.
+
+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")

base-commit: b226a1007a9111adacb05984b8d74def24257dce
prerequisite-patch-id: cf5c00ff7ab68e16a9c83d294d57d08c1745dfeb
--
2.47.1
G
G
gay wrote 4 days ago
c761fdae6b39a8360402febc64c9cdf7@disroot.org
Hi,

Sorry about that, I expected it to be used only to build packages for
Guix, not as package manager.

It's surprising MicroHs itself ignores MHSDIR, considering it didn't
ignore this variable while building MicroCabal.

Considering inputs are runtime dependencies, shouldn't they go to
propagated-inputs?
L
L
Lars-Dominik Braun wrote 3 days ago
(address . gay@disroot.org)(address . 75787@debbugs.gnu.org)
Z59U2uILNQoRcWcp@noor.fritz.box
Hi,

Toggle quote (3 lines)
> Sorry about that, I expected it to be used only to build packages for
> Guix, not as package manager.

do you have an example for that? I would like to be able to do both,
if possible.

Toggle quote (3 lines)
> It's surprising MicroHs itself ignores MHSDIR, considering it didn't
> ignore this variable while building MicroCabal.

I believe MicroCabal explicitly unsets the search path (via `-i`
without any argument).

Toggle quote (3 lines)
> Considering inputs are runtime dependencies, shouldn't they go to
> propagated-inputs?

Yes and no. Whenever possible, runtime dependencies should be plain
inputs. The key here is that their paths are baked into the resulting
mcabal binary via the 'fix-paths phase. propagated-inputs is (imo)
a last-resort is case that is not feasible or desired.

Lars
G
G
gay wrote 25 hours ago
aa6fd13075a1a9e06c9238e95b97b189@disroot.org
Toggle quote (3 lines)
> do you have an example for that? I would like to be able to do both,
> if possible.

Nope, no idea yet, it might need slight modification to make such
example possible, because there are different places where to lookup
packages and where to install packages, to figure this out the only
documentation available is source code.

Toggle quote (3 lines)
> I believe MicroCabal explicitly unsets the search path (via `-i`
> without any argument).

Looks like intention to rebuild MicroHs to be installed as package
managed by MicroCabal, except it doesn't know how to do that, because
base (and few more packages) are expected to be backed into Haskell
implementation, but then in standalone package manager scenario you can
use old compiler (unknown to MicroCabal) and old MicroCabal (also
unknown to MicroCabal) to build and install new compiler, new base and
new MicroCabal. I have no idea what to do about other packages expected
to be baked into implementation, maybe same workflow - clone git repo
manually.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75787@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75787
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch