import: opam: Use dune-build-system when possible.
* guix/import/opam.scm (opam->guix-package): Detect when dune can be used.
This commit is contained in:
parent
3e159dd0a4
commit
7b1c7ecdfb
|
@ -247,39 +247,55 @@ path to the repository."
|
||||||
(url-dict (metadata-ref opam-content "url"))
|
(url-dict (metadata-ref opam-content "url"))
|
||||||
(source-url (metadata-ref url-dict "src"))
|
(source-url (metadata-ref url-dict "src"))
|
||||||
(requirements (metadata-ref opam-content "depends"))
|
(requirements (metadata-ref opam-content "depends"))
|
||||||
(dependencies (dependency-list->names requirements))
|
(dependencies (filter
|
||||||
|
(lambda (name)
|
||||||
|
(not (member name '("dune" "jbuilder"))))
|
||||||
|
(dependency-list->names requirements)))
|
||||||
|
(native-dependencies (depends->native-inputs requirements))
|
||||||
(inputs (dependency-list->inputs (depends->inputs requirements)))
|
(inputs (dependency-list->inputs (depends->inputs requirements)))
|
||||||
(native-inputs (dependency-list->inputs (depends->native-inputs requirements))))
|
(native-inputs (dependency-list->inputs
|
||||||
(call-with-temporary-output-file
|
;; Do not add dune nor jbuilder since they are
|
||||||
(lambda (temp port)
|
;; implicit inputs of the dune-build-system.
|
||||||
(and (url-fetch source-url temp)
|
(filter
|
||||||
(values
|
(lambda (name)
|
||||||
`(package
|
(not (member name '("dune" "jbuilder"))))
|
||||||
(name ,(ocaml-name->guix-name name))
|
native-dependencies))))
|
||||||
(version ,(if (string-prefix? "v" version)
|
;; If one of these are required at build time, it means we
|
||||||
(substring version 1)
|
;; can use the much nicer dune-build-system.
|
||||||
version))
|
(let ((use-dune? (or (member "dune" native-dependencies)
|
||||||
(source
|
(member "jbuilder" native-dependencies))))
|
||||||
(origin
|
(call-with-temporary-output-file
|
||||||
(method url-fetch)
|
(lambda (temp port)
|
||||||
(uri ,source-url)
|
(and (url-fetch source-url temp)
|
||||||
(sha256 (base32 ,(guix-hash-url temp)))))
|
(values
|
||||||
(build-system ocaml-build-system)
|
`(package
|
||||||
,@(if (null? inputs)
|
(name ,(ocaml-name->guix-name name))
|
||||||
'()
|
(version ,(if (string-prefix? "v" version)
|
||||||
`((inputs ,(list 'quasiquote inputs))))
|
(substring version 1)
|
||||||
,@(if (null? native-inputs)
|
version))
|
||||||
'()
|
(source
|
||||||
`((native-inputs ,(list 'quasiquote native-inputs))))
|
(origin
|
||||||
,@(if (equal? name (guix-name->opam-name (ocaml-name->guix-name name)))
|
(method url-fetch)
|
||||||
'()
|
(uri ,source-url)
|
||||||
`((properties
|
(sha256 (base32 ,(guix-hash-url temp)))))
|
||||||
,(list 'quasiquote `((upstream-name . ,name))))))
|
(build-system ,(if use-dune?
|
||||||
(home-page ,(metadata-ref opam-content "homepage"))
|
'dune-build-system
|
||||||
(synopsis ,(metadata-ref opam-content "synopsis"))
|
'ocaml-build-system))
|
||||||
(description ,(metadata-ref opam-content "description"))
|
,@(if (null? inputs)
|
||||||
(license #f))
|
'()
|
||||||
dependencies))))))
|
`((inputs ,(list 'quasiquote inputs))))
|
||||||
|
,@(if (null? native-inputs)
|
||||||
|
'()
|
||||||
|
`((native-inputs ,(list 'quasiquote native-inputs))))
|
||||||
|
,@(if (equal? name (guix-name->opam-name (ocaml-name->guix-name name)))
|
||||||
|
'()
|
||||||
|
`((properties
|
||||||
|
,(list 'quasiquote `((upstream-name . ,name))))))
|
||||||
|
(home-page ,(metadata-ref opam-content "homepage"))
|
||||||
|
(synopsis ,(metadata-ref opam-content "synopsis"))
|
||||||
|
(description ,(metadata-ref opam-content "description"))
|
||||||
|
(license #f))
|
||||||
|
dependencies)))))))
|
||||||
|
|
||||||
(define (opam-recursive-import package-name)
|
(define (opam-recursive-import package-name)
|
||||||
(recursive-import package-name #f
|
(recursive-import package-name #f
|
||||||
|
|
Loading…
Reference in New Issue