From: Philip Munksgaard <philip@munksgaard.me>
To: 54729@debbugs.gnu.org
Cc: Philip Munksgaard <philip@munksgaard.me>
Subject: [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries
Date: Tue, 5 Apr 2022 17:15:29 +0200 [thread overview]
Message-ID: <8a396a9803fc35ee63f01e608f87ffb16863bc6d.1649171729.git.philip@munksgaard.me> (raw)
As discussed in #53655 [0], haskell-build-system.scm does not currently
support packages which contain multiple libraries, such as attoparsec
[1]. Such libraries are often used for internal or convenience libraries, as
detailed in the documentation [2].
The current state of affairs means that attoparsec and any other libraries
with similar structure cannot be built on guix, nor can any library or
executable that depends on such a library.
Instead of assuming that `runhaskell Setup.hs --gen-pkg-config=...` always
outputs a single file, we detect whether the result was a directory. If so, we
need to handle each file independently in lexicographic order by calling the
new private function `install-from-config-file`.
Because `install-transitive-deps` can now be called multiple times for each
call to `register`, it has also been amended to support the files already
installed.
0: https://issues.guix.gnu.org/53655
1: https://hackage.haskell.org/package/attoparsec-0.14.4/attoparsec.cabal
2: https://downloads.haskell.org/cabal/Cabal-3.0.0.0/doc/users-guide/installing-packages.html#cmdoption-setup-register-gen-pkg-config
---
guix/build/haskell-build-system.scm | 34 ++++++++++++++++++-----------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index ef6cb316ee..e827e23aba 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -217,11 +217,13 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
(if (not (vhash-assoc id seen))
(let ((dep-conf (string-append src "/" id ".conf"))
(dep-conf* (string-append dest "/" id ".conf")))
- (when (not (file-exists? dep-conf))
+ (unless (file-exists? dep-conf*)
+ (when (not (file-exists? dep-conf))
(error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file)))
- (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
- (loop (vhash-cons id #t seen)
- (append lst (conf-depends dep-conf))))
+ (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead?
+
+ (loop (vhash-cons id #t seen)
+ (append lst (conf-depends dep-conf*)))))
(loop seen tail))))))
(let* ((out (assoc-ref outputs "out"))
@@ -234,13 +236,12 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
"/ghc-" version
"/" name ".conf.d"))
(id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
- (config-file (string-append out "/" name ".conf"))
+ (config-output (string-append out "/" name ".conf"))
(params
- (list (string-append "--gen-pkg-config=" config-file))))
+ (list (string-append "--gen-pkg-config=" config-output))))
(run-setuphs "register" params)
- ;; The conf file is created only when there is a library to register.
- (when (file-exists? config-file)
- (mkdir-p config-dir)
+
+ (define (install-from-config-file config-file)
(let* ((contents (call-with-input-file config-file read-string))
(config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
@@ -270,10 +271,17 @@ (define* (register #:key name system inputs outputs #:allow-other-keys)
(install-transitive-deps config-file %tmp-db-dir config-dir)
(rename-file config-file
(string-append config-dir "/"
- config-file-name+id ".conf"))
- (invoke "ghc-pkg"
- (string-append "--package-db=" config-dir)
- "recache")))
+ config-file-name+id ".conf"))))
+
+ ;; The conf file is created only when there is a library to register.
+ (when (file-exists? config-output)
+ (mkdir-p config-dir)
+ (if (file-is-directory? config-output)
+ (for-each install-from-config-file (find-files config-output))
+ (install-from-config-file config-output))
+ (invoke "ghc-pkg"
+ (string-append "--package-db=" config-dir)
+ "recache"))
#t))
(define* (check #:key tests? test-target #:allow-other-keys)
--
2.35.1
next reply other threads:[~2022-04-05 20:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 15:15 Philip Munksgaard [this message]
2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 1/2] build: haskell-build-system: Remove trailing #t zimoun
2022-04-06 19:19 ` [bug#54729] [PATCH core-updates v2 2/2] build: haskell-build-system: Support multiple libraries zimoun
2022-04-06 19:23 ` [bug#54729] [PATCH] build: haskell-build-system: Support packages w. " zimoun
2022-04-07 6:08 ` Lars-Dominik Braun
2022-04-07 6:49 ` Philip Munksgaard
2022-04-07 8:25 ` Philip Munksgaard
2022-04-07 7:35 ` zimoun
2022-04-13 18:59 ` Philip Munksgaard
2022-04-14 18:21 ` Lars-Dominik Braun
2022-04-15 8:19 ` Philip Munksgaard
2022-09-23 9:42 ` itd
2022-12-21 12:48 ` itd
2022-12-23 14:03 ` Philip Munksgaard
2023-01-06 11:51 ` Lars-Dominik Braun
2023-01-12 17:30 ` itd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a396a9803fc35ee63f01e608f87ffb16863bc6d.1649171729.git.philip@munksgaard.me \
--to=philip@munksgaard.me \
--cc=54729@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.