diff options
author | Danny Milosavljevic <dannym@scratchpost.org> | 2018-07-13 15:54:41 +0200 |
---|---|---|
committer | Danny Milosavljevic <dannym@scratchpost.org> | 2018-07-27 11:42:53 +0200 |
commit | d804d0b9eff8e7fcdfe289bcd7e49a0d3aa2a062 (patch) | |
tree | f2383637af131ad1c408c566ecde061a6488b970 | |
parent | 9dafb647115ecf7f6dc4fde443621501e993d860 (diff) | |
download | patches-d804d0b9eff8e7fcdfe289bcd7e49a0d3aa2a062.tar patches-d804d0b9eff8e7fcdfe289bcd7e49a0d3aa2a062.tar.gz |
import: hackage: Emit native-inputs in the importer.
* 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.
-rw-r--r-- | guix/import/cabal.scm | 15 | ||||
-rw-r--r-- | guix/import/hackage.scm | 53 |
2 files changed, 50 insertions, 18 deletions
diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index 4b2bfd4a25..1b8bda6f4e 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 eb9e1d7d82..6f80d84b70 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)) |