[PATCH] import: hackage: Emit native-inputs in the importer.

  • Done
  • quality assurance status badge
Details
One participant
  • Danny Milosavljevic
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 7 years ago
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180713135441.15029-1-dannym@scratchpost.org
* guix/import/cabal.scm (cabal-custom-setup-dependencies): Export.
(cabal-package-custom-setup): Export.
(<cabal-package>): New field "custom-setup".
(make-cabal-package): Modify.
(eval-cabal): Modify.
* guix/import/hackage.scm (cabal-dependencies->names): Factor out...
(cabal-test-dependencies->names): ...this.
(cabal-custom-setup-dependencies->names): New procedure.
(hackage-module->sexp): Modify.
---
guix/import/cabal.scm | 15 ++++++++++----
guix/import/hackage.scm | 53 ++++++++++++++++++++++++++++++++++++-------------
2 files changed, 50 insertions(+), 18 deletions(-)

Toggle diff (142 lines)
diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm
index 4b2bfd4a2..1b8bda6f4 100644
--- a/guix/import/cabal.scm
+++ b/guix/import/cabal.scm
@@ -34,6 +34,8 @@
#:export (read-cabal
eval-cabal
+ cabal-custom-setup-dependencies
+
cabal-package?
cabal-package-name
cabal-package-version
@@ -47,6 +49,7 @@
cabal-package-test-suites
cabal-package-flags
cabal-package-eval-environment
+ cabal-package-custom-setup
cabal-source-repository?
cabal-source-repository-use-case
@@ -616,7 +619,7 @@ If #f use the function 'port-filename' to obtain it."
(make-cabal-package name version license home-page source-repository
synopsis description
executables lib test-suites
- flags eval-environment)
+ flags eval-environment custom-setup)
cabal-package?
(name cabal-package-name)
(version cabal-package-version)
@@ -629,7 +632,8 @@ If #f use the function 'port-filename' to obtain it."
(lib cabal-package-library) ; 'library' is a Scheme keyword
(test-suites cabal-package-test-suites)
(flags cabal-package-flags)
- (eval-environment cabal-package-eval-environment)) ; alist
+ (eval-environment cabal-package-eval-environment) ; alist
+ (custom-setup cabal-package-custom-setup))
(set-record-type-printer! <cabal-package>
(lambda (package port)
@@ -826,10 +830,13 @@ See the manual for limitations.")))))))
(lib (make-cabal-section evaluated-sexp 'library))
(test-suites (make-cabal-section evaluated-sexp 'test-suite))
(flags (make-cabal-section evaluated-sexp 'flag))
- (eval-environment '()))
+ (eval-environment '())
+ (custom-setup (match
+ (make-cabal-section evaluated-sexp 'custom-setup)
+ ((x) x))))
(make-cabal-package name version license home-page-or-hackage
source-repository synopsis description executables lib
- test-suites flags eval-environment)))
+ test-suites flags eval-environment custom-setup)))
((compose cabal-evaluated-sexp->package eval) cabal-sexp))
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index eb9e1d7d8..6f80d84b7 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -150,10 +150,9 @@ version."
(_ #f)))
-(define (cabal-dependencies->names cabal include-test-dependencies?)
- "Return the list of dependencies names from the CABAL package object. If
-INCLUDE-TEST-DEPENDENCIES? is #f, do not include dependencies required by test
-suites."
+(define (cabal-dependencies->names cabal)
+ "Return the list of dependencies names from the CABAL package object,
+not including test suite dependencies or custom-setup dependencies."
(let* ((lib (cabal-package-library cabal))
(lib-deps (if (pair? lib)
(map cabal-dependency-name
@@ -163,15 +162,25 @@ suites."
(exe-deps (if (pair? exe)
(map cabal-dependency-name
(append-map cabal-executable-dependencies exe))
- '()))
- (ts (cabal-package-test-suites cabal))
- (ts-deps (if (pair? ts)
- (map cabal-dependency-name
- (append-map cabal-test-suite-dependencies ts))
'())))
- (if include-test-dependencies?
- (delete-duplicates (append lib-deps exe-deps ts-deps))
- (delete-duplicates (append lib-deps exe-deps)))))
+ (delete-duplicates (append lib-deps exe-deps))))
+
+(define (cabal-test-dependencies->names cabal)
+ "Return the list of test suite dependencies from the CABAL package
+object."
+ (let* ((ts (cabal-package-test-suites cabal))
+ (ts-deps (if (pair? ts)
+ (map cabal-dependency-name
+ (append-map cabal-test-suite-dependencies ts))
+ '())))
+ ts-deps))
+
+(define (cabal-custom-setup-dependencies->names cabal)
+ "Return the list of custom-setup dependencies from the CABAL package
+object."
+ (let* ((custom-setup-dependencies (and=> (cabal-package-custom-setup cabal)
+ cabal-custom-setup-dependencies)))
+ (map cabal-dependency-name custom-setup-dependencies)))
(define (filter-dependencies dependencies own-name)
"Filter the dependencies included with the GHC compiler from DEPENDENCIES, a
@@ -199,8 +208,23 @@ representation of a Cabal file as produced by 'read-cabal'."
(map hackage-name->package-name
((compose (cut filter-dependencies <>
(cabal-package-name cabal))
- (cut cabal-dependencies->names <>
- include-test-dependencies?))
+ (cut cabal-dependencies->names <>))
+ cabal))))
+ (map (lambda (name)
+ (list name (list 'unquote (string->symbol name))))
+ names)))
+
+ (define native-dependencies
+ (let ((names
+ (map hackage-name->package-name
+ ((compose (cut filter-dependencies <>
+ (cabal-package-name cabal))
+ ;; FIXME: Check include-test-dependencies?
+ (lambda (cabal)
+ (append (if include-test-dependencies?
+ (cabal-test-dependencies->names cabal)
+ '())
+ (cabal-custom-setup-dependencies->names cabal))))
cabal))))
(map (lambda (name)
(list name (list 'unquote (string->symbol name))))
@@ -234,6 +258,7 @@ representation of a Cabal file as produced by 'read-cabal'."
"failed to download tar archive")))))
(build-system haskell-build-system)
,@(maybe-inputs 'inputs dependencies)
+ ,@(maybe-inputs 'native-inputs native-dependencies)
,@(maybe-arguments)
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
Danny Milosavljevic wrote 7 years ago
(no subject)
(address . control@debbugs.gnu.org)
20180727114141.5fb6bc0f@scratchpost.org
close 32139
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlta6NUACgkQ5xo1VCww
uqV35Qf/dVfiY8PuBO/cCTFK5dGfgp79bfJ/VaSNFPe4X0EuBWAN+Mkit2soysHp
yGv9llj+EcwrmJkUcp59LIStQ+qxhkUSa2Q6HZYDiiKQNKf9hsm+cMaxhk445jf6
0EwyV9G56dJto/oM+PXW7yG7aX+MPr+yEaiUjHpK6S236771a5MCVG9NEO9I5KUk
Magbdpfc7Ro0uFz0mg5erLaSaTXpSDsQ0OYjYflw86z8KRfGdmrMlphAANVedsCQ
k/VlHrsbUFUkFqEViO5yrNLAAiH1J6q/yRGF71VLS7JDbX/aioF23mGPIi1rkmTH
ktKjmgMXVSp1p0onErStkgohDFlegA==
=9U8Y
-----END PGP SIGNATURE-----


?
Your comment

This issue is archived.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 32139
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
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help