2015-03-08 07:48:38 +01:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
|
2016-03-23 04:40:38 +01:00
|
|
|
;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
|
Correct name and email address for ng0.
* .mailmap, Makefile.am, doc/guix.de.texi, doc/guix.fr.texi,
doc/guix.texi, etc/completion/fish/guix.fish,
gnu/packages/accessibility.scm, gnu/packages/admin.scm,
gnu/packages/audio.scm, gnu/packages/autotools.scm,
gnu/packages/cdrom.scm, gnu/packages/check.scm,
gnu/packages/cinnamon.scm, gnu/packages/compression.scm,
gnu/packages/crypto.scm, gnu/packages/databases.scm,
gnu/packages/django.scm, gnu/packages/dns.scm, gnu/packages/elixir.scm,
gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm,
gnu/packages/enlightenment.scm, gnu/packages/erlang.scm,
gnu/packages/fonts.scm, gnu/packages/fontutils.scm,
gnu/packages/forth.scm, gnu/packages/fvwm.scm, gnu/packages/games.scm,
gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm,
gnu/packages/gnupg.scm, gnu/packages/gnuzilla.scm, gnu/packages/gtk.scm,
gnu/packages/guile-wm.scm,gnu/packages/guile-xyz.scm,
gnu/packages/haskell-check.scm, gnu/packages/haskell-crypto.scm,
gnu/packages/haskell.scm, gnu/packages/image-viewers.scm,
gnu/packages/image.scm, gnu/packages/irc.scm,
gnu/packages/language.scm, gnu/packages/libcanberra.scm,
gnu/packages/linux.scm, gnu/packages/lisp.scm, gnu/packages/lolcode.scm,
gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/mail.scm,
gnu/packages/markup.scm, gnu/packages/mate.scm, gnu/packages/maths.scm,
gnu/packages/mc.scm, gnu/packages/messaging.scm, gnu/packages/music.scm,
gnu/packages/ncurses.scm, gnu/packages/networking.scm,
gnu/packages/nickle.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm,
gnu/packages/perl-check.scm, gnu/packages/perl.scm,
gnu/packages/python-compression.scm, gnu/packages/python-crypto.scm,
gnu/packages/python-web.scm, gnu/packages/python-xyz.scm,
gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm,
gnu/packages/rust.scm, gnu/packages/scheme.scm,
gnu/packages/serialization.scm, gnu/packages/shells.scm,
gnu/packages/ssh.scm, gnu/packages/suckless.scm, gnu/packages/tbb.scm,
gnu/packages/telephony.scm, gnu/packages/text-editors.scm,
gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm,
gnu/packages/tor.scm, gnu/packages/version-control.scm,
gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/web.scm,
gnu/packages/wm.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm,
gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/services/certbot.scm,
gnu/services/desktop.scm, gnu/services/version-control.scm,
gnu/services/web.scm, guix/import/hackage.scm, guix/licenses.scm:
Correct name and email address for ng0.
Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr>
2019-03-14 10:33:38 +01:00
|
|
|
;;; Copyright © 2016 ng0 <ng0@n0.is>
|
2018-08-07 18:00:16 +02:00
|
|
|
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
|
2019-07-04 09:57:30 +02:00
|
|
|
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
|
2015-03-08 07:48:38 +01:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (guix import hackage)
|
|
|
|
#:use-module (ice-9 match)
|
2016-03-23 04:44:51 +01:00
|
|
|
#:use-module (ice-9 regex)
|
2017-02-09 17:05:41 +01:00
|
|
|
#:use-module (srfi srfi-34)
|
2015-03-08 07:48:38 +01:00
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
#:use-module (srfi srfi-11)
|
|
|
|
#:use-module (srfi srfi-1)
|
2016-03-23 04:44:51 +01:00
|
|
|
#:use-module ((guix download) #:select (download-to-store url-fetch))
|
2015-11-14 15:15:00 +01:00
|
|
|
#:use-module ((guix utils) #:select (package-name->name+version
|
|
|
|
canonical-newline-port))
|
2016-03-23 04:38:54 +01:00
|
|
|
#:use-module (guix http-client)
|
2018-08-08 15:29:18 +02:00
|
|
|
#:use-module ((guix import utils) #:select (factorize-uri recursive-import))
|
2015-04-26 11:22:29 +02:00
|
|
|
#:use-module (guix import cabal)
|
2015-03-08 07:48:38 +01:00
|
|
|
#:use-module (guix store)
|
Switch to Guile-Gcrypt.
This removes (guix hash) and (guix pk-crypto), which now live as part of
Guile-Gcrypt (version 0.1.0.)
* guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm,
tests/hash.scm, tests/pk-crypto.scm: Remove.
* configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and
LIBGCRYPT_LIBDIR assignments.
* m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove.
* README: Add Guile-Gcrypt to the dependencies; move libgcrypt as
"required unless --disable-daemon".
* doc/guix.texi (Requirements): Likewise.
* gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm,
guix/git.scm, guix/http-client.scm, guix/import/cpan.scm,
guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm,
guix/import/gnu.scm, guix/import/hackage.scm,
guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm,
guix/pki.scm, guix/scripts/archive.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/scripts/pack.scm,
guix/scripts/publish.scm, guix/scripts/refresh.scm,
guix/scripts/substitute.scm, guix/store.scm,
guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm,
tests/builders.scm, tests/challenge.scm, tests/cpan.scm,
tests/crate.scm, tests/derivations.scm, tests/gem.scm,
tests/nar.scm, tests/opam.scm, tests/pki.scm,
tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm,
tests/store.scm, tests/substitute.scm: Adjust imports.
* gnu/system/vm.scm: Likewise.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(expression->derivation-in-linux-vm)[config]: Remove.
(iso9660-image)[config]: Remove.
(qemu-image)[config]: Remove.
(system-docker-image)[config]: Remove.
* guix/scripts/pack.scm: Adjust imports.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(self-contained-tarball)[build]: Call 'make-config.scm' without
#:libgcrypt argument.
(squashfs-image)[libgcrypt]: Remove.
[build]: Call 'make-config.scm' without #:libgcrypt.
(docker-image)[config, json]: Remove.
[build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from
the imported modules.
* guix/self.scm (specification->package): Remove "libgcrypt", add
"guile-gcrypt".
(compiled-guix): Remove #:libgcrypt.
[guile-gcrypt]: New variable.
[dependencies]: Add it.
[*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call.
Add #:extensions.
[*config*]: Remove #:libgcrypt from 'make-config.scm' call.
(%dependency-variables): Remove %libgcrypt.
(make-config.scm): Remove #:libgcrypt.
* build-aux/build-self.scm (guile-gcrypt): New variable.
(make-config.scm): Remove #:libgcrypt.
(build-program)[fake-gcrypt-hash]: New variable.
Add (gcrypt hash) to the imported modules. Adjust load path
assignments.
* gnu/packages/package-management.scm (guix)[propagated-inputs]: Add
GUILE-GCRYPT.
[arguments]: In 'wrap-program' phase, add GUILE-GCRYPT to the search
path.
2018-08-31 17:07:07 +02:00
|
|
|
#:use-module (gcrypt hash)
|
2015-03-08 07:48:38 +01:00
|
|
|
#:use-module (guix base32)
|
2018-08-08 15:29:18 +02:00
|
|
|
#:use-module (guix memoization)
|
2016-03-23 04:44:51 +01:00
|
|
|
#:use-module (guix upstream)
|
|
|
|
#:use-module (guix packages)
|
2015-03-08 07:48:38 +01:00
|
|
|
#:use-module ((guix utils) #:select (call-with-temporary-output-file))
|
2016-03-23 04:44:51 +01:00
|
|
|
#:export (hackage->guix-package
|
2018-08-08 15:29:18 +02:00
|
|
|
hackage-recursive-import
|
2017-02-06 18:19:26 +01:00
|
|
|
%hackage-updater
|
|
|
|
|
|
|
|
guix-package->hackage-name
|
2018-08-20 17:38:56 +02:00
|
|
|
hackage-name->package-name
|
2017-02-06 18:19:26 +01:00
|
|
|
hackage-fetch
|
|
|
|
hackage-source-url
|
|
|
|
hackage-cabal-url
|
|
|
|
hackage-package?))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define ghc-standard-libraries
|
2019-05-25 22:11:02 +02:00
|
|
|
;; List of libraries distributed with ghc (8.4.3).
|
2019-07-04 09:57:30 +02:00
|
|
|
;; Contents of ...-ghc-8.4.3/lib/ghc-8.4.3.
|
2019-05-25 22:11:02 +02:00
|
|
|
'("ghc"
|
|
|
|
"cabal" ;; in the output of `ghc-pkg list` Cabal is uppercased, but
|
|
|
|
;; hackage-name->package-name takes this into account.
|
|
|
|
"win32" ;; similarly uppercased
|
|
|
|
"array"
|
2015-03-08 07:48:38 +01:00
|
|
|
"base"
|
|
|
|
"binary"
|
|
|
|
"bytestring"
|
|
|
|
"containers"
|
2015-10-21 15:46:25 +02:00
|
|
|
"deepseq"
|
|
|
|
"directory"
|
|
|
|
"filepath"
|
2019-07-04 09:57:30 +02:00
|
|
|
"ghc"
|
2019-05-25 22:11:02 +02:00
|
|
|
"ghc-boot"
|
2019-07-04 09:57:30 +02:00
|
|
|
"ghc-boot-th"
|
2019-05-25 22:11:02 +02:00
|
|
|
"ghc-compact"
|
2015-03-08 07:48:38 +01:00
|
|
|
"ghc-prim"
|
2019-05-25 22:11:02 +02:00
|
|
|
"ghci"
|
2015-10-21 15:46:25 +02:00
|
|
|
"haskeline"
|
|
|
|
"hpc"
|
2015-03-08 07:48:38 +01:00
|
|
|
"integer-gmp"
|
2019-05-25 22:11:02 +02:00
|
|
|
"mtl"
|
|
|
|
"parsec"
|
2019-07-04 09:57:30 +02:00
|
|
|
"pretty"
|
2015-03-08 07:48:38 +01:00
|
|
|
"process"
|
2019-07-04 09:57:30 +02:00
|
|
|
"stm"
|
2015-10-21 15:46:25 +02:00
|
|
|
"template-haskell"
|
2019-07-04 09:57:30 +02:00
|
|
|
"terminfo"
|
2019-05-25 22:11:02 +02:00
|
|
|
"text"
|
2015-10-21 15:46:25 +02:00
|
|
|
"time"
|
|
|
|
"transformers"
|
2015-03-08 07:48:38 +01:00
|
|
|
"unix"
|
2015-10-21 15:46:25 +02:00
|
|
|
"xhtml"))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define package-name-prefix "ghc-")
|
|
|
|
|
2016-03-23 04:40:38 +01:00
|
|
|
(define (hackage-source-url name version)
|
|
|
|
"Given a Hackage package NAME and VERSION, return a url to the source
|
|
|
|
tarball."
|
2016-08-30 14:08:21 +02:00
|
|
|
(string-append "https://hackage.haskell.org/package/" name
|
2016-03-23 04:40:38 +01:00
|
|
|
"/" name "-" version ".tar.gz"))
|
|
|
|
|
|
|
|
(define* (hackage-cabal-url name #:optional version)
|
|
|
|
"Given a Hackage package NAME and VERSION, return a url to the corresponding
|
|
|
|
.cabal file on Hackage. If VERSION is #f or missing, the url for the latest
|
|
|
|
version is returned."
|
|
|
|
(if version
|
2016-08-30 14:08:21 +02:00
|
|
|
(string-append "https://hackage.haskell.org/package/"
|
2016-03-23 04:40:38 +01:00
|
|
|
name "-" version "/" name ".cabal")
|
2016-08-30 14:08:21 +02:00
|
|
|
(string-append "https://hackage.haskell.org/package/"
|
2016-03-23 04:40:38 +01:00
|
|
|
name "/" name ".cabal")))
|
|
|
|
|
2015-03-08 07:48:38 +01:00
|
|
|
(define (hackage-name->package-name name)
|
2015-04-26 11:22:29 +02:00
|
|
|
"Given the NAME of a Cabal package, return the corresponding Guix name."
|
2015-03-08 07:48:38 +01:00
|
|
|
(if (string-prefix? package-name-prefix name)
|
|
|
|
(string-downcase name)
|
|
|
|
(string-append package-name-prefix (string-downcase name))))
|
|
|
|
|
2016-03-23 04:44:51 +01:00
|
|
|
(define guix-package->hackage-name
|
|
|
|
(let ((uri-rx (make-regexp "https?://hackage.haskell.org/package/([^/]+)/.*"))
|
|
|
|
(name-rx (make-regexp "(.*)-[0-9\\.]+")))
|
|
|
|
(lambda (package)
|
|
|
|
"Given a Guix package name, return the corresponding Hackage name."
|
|
|
|
(let* ((source-url (and=> (package-source package) origin-uri))
|
|
|
|
(name (match:substring (regexp-exec uri-rx source-url) 1)))
|
|
|
|
(match (regexp-exec name-rx name)
|
|
|
|
(#f name)
|
|
|
|
(m (match:substring m 1)))))))
|
|
|
|
|
2019-06-13 21:39:14 +02:00
|
|
|
(define (read-cabal-and-hash port)
|
|
|
|
"Read a Cabal file from PORT and return it and its hash in nix-base32
|
|
|
|
format as two values."
|
|
|
|
(let-values (((port get-hash) (open-sha256-input-port port)))
|
|
|
|
(values (read-cabal (canonical-newline-port port))
|
|
|
|
(bytevector->nix-base32-string (get-hash)))))
|
|
|
|
|
|
|
|
(define (hackage-fetch-and-hash name-version)
|
|
|
|
"Fetch the latest Cabal revision for the package NAME-VERSION, and return
|
|
|
|
two values: the parsed Cabal file and its hash in nix-base32 format. If the
|
|
|
|
version part is omitted from the package name, then fetch the latest
|
|
|
|
version. On failure, both return values will be #f."
|
|
|
|
(guard (c ((and (http-get-error? c)
|
|
|
|
(= 404 (http-get-error-code c)))
|
|
|
|
(values #f #f))) ;"expected" if package is unknown
|
|
|
|
(let*-values (((name version) (package-name->name+version name-version))
|
|
|
|
((url) (hackage-cabal-url name version))
|
|
|
|
((port _) (http-fetch url))
|
|
|
|
((cabal hash) (read-cabal-and-hash port)))
|
|
|
|
(close-port port)
|
|
|
|
(values cabal hash))))
|
|
|
|
|
2015-03-08 07:48:38 +01:00
|
|
|
(define (hackage-fetch name-version)
|
|
|
|
"Return the Cabal file for the package NAME-VERSION, or #f on failure. If
|
|
|
|
the version part is omitted from the package name, then return the latest
|
|
|
|
version."
|
2019-06-13 21:39:14 +02:00
|
|
|
(let-values (((cabal hash) (hackage-fetch-and-hash name-version)))
|
|
|
|
cabal))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define string->license
|
|
|
|
;; List of valid values from
|
|
|
|
;; https://www.haskell.org
|
|
|
|
;; /cabal/release/cabal-latest/doc/API/Cabal/Distribution-License.html.
|
|
|
|
(match-lambda
|
|
|
|
("GPL-2" 'gpl2)
|
|
|
|
("GPL-3" 'gpl3)
|
|
|
|
("GPL" "'gpl??")
|
|
|
|
("AGPL-3" 'agpl3)
|
|
|
|
("AGPL" "'agpl??")
|
|
|
|
("LGPL-2.1" 'lgpl2.1)
|
|
|
|
("LGPL-3" 'lgpl3)
|
|
|
|
("LGPL" "'lgpl??")
|
|
|
|
("BSD2" 'bsd-2)
|
|
|
|
("BSD3" 'bsd-3)
|
2019-05-25 22:09:51 +02:00
|
|
|
("BSD-3-Clause" 'bsd-3)
|
2015-03-08 07:48:38 +01:00
|
|
|
("MIT" 'expat)
|
|
|
|
("ISC" 'isc)
|
|
|
|
("MPL" 'mpl2.0)
|
|
|
|
("Apache-2.0" 'asl2.0)
|
2019-05-25 22:09:51 +02:00
|
|
|
("PublicDomain" 'public-domain)
|
2015-03-08 07:48:38 +01:00
|
|
|
((x) (string->license x))
|
|
|
|
((lst ...) `(list ,@(map string->license lst)))
|
|
|
|
(_ #f)))
|
|
|
|
|
2015-04-26 11:22:29 +02:00
|
|
|
|
2018-07-13 15:54:41 +02:00
|
|
|
(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."
|
2015-04-26 11:22:29 +02:00
|
|
|
(let* ((lib (cabal-package-library cabal))
|
|
|
|
(lib-deps (if (pair? lib)
|
|
|
|
(map cabal-dependency-name
|
|
|
|
(append-map cabal-library-dependencies lib))
|
|
|
|
'()))
|
|
|
|
(exe (cabal-package-executables cabal))
|
|
|
|
(exe-deps (if (pair? exe)
|
|
|
|
(map cabal-dependency-name
|
|
|
|
(append-map cabal-executable-dependencies exe))
|
|
|
|
'())))
|
2018-07-13 15:54:41 +02:00
|
|
|
(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."
|
2018-08-07 18:00:16 +02:00
|
|
|
(let* ((custom-setup-dependencies (or (and=> (cabal-package-custom-setup cabal)
|
|
|
|
cabal-custom-setup-dependencies)
|
|
|
|
'())))
|
2018-07-13 15:54:41 +02:00
|
|
|
(map cabal-dependency-name custom-setup-dependencies)))
|
2015-04-26 11:22:29 +02:00
|
|
|
|
|
|
|
(define (filter-dependencies dependencies own-name)
|
|
|
|
"Filter the dependencies included with the GHC compiler from DEPENDENCIES, a
|
|
|
|
list with the names of dependencies. OWN-NAME is the name of the Cabal
|
|
|
|
package being processed and is used to filter references to itself."
|
|
|
|
(filter (lambda (d) (not (member (string-downcase d)
|
|
|
|
(cons own-name ghc-standard-libraries))))
|
|
|
|
dependencies))
|
|
|
|
|
2019-06-13 21:39:14 +02:00
|
|
|
(define* (hackage-module->sexp cabal cabal-hash
|
|
|
|
#:key (include-test-dependencies? #t))
|
2015-04-26 11:22:29 +02:00
|
|
|
"Return the `package' S-expression for a Cabal package. CABAL is the
|
2019-06-13 21:39:14 +02:00
|
|
|
representation of a Cabal file as produced by 'read-cabal'. CABAL-HASH is
|
|
|
|
the hash of the Cabal file."
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define name
|
2015-04-26 11:22:29 +02:00
|
|
|
(cabal-package-name cabal))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define version
|
2015-04-26 11:22:29 +02:00
|
|
|
(cabal-package-version cabal))
|
2019-06-13 21:39:14 +02:00
|
|
|
|
|
|
|
(define revision
|
|
|
|
(cabal-package-revision cabal))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define source-url
|
2016-03-23 04:40:38 +01:00
|
|
|
(hackage-source-url name version))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
2018-08-08 15:29:18 +02:00
|
|
|
(define hackage-dependencies
|
|
|
|
((compose (cut filter-dependencies <>
|
|
|
|
(cabal-package-name cabal))
|
|
|
|
(cut cabal-dependencies->names <>))
|
|
|
|
cabal))
|
|
|
|
|
|
|
|
(define hackage-native-dependencies
|
2018-09-22 18:48:50 +02:00
|
|
|
(lset-difference
|
|
|
|
equal?
|
|
|
|
((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)
|
|
|
|
hackage-dependencies))
|
2018-08-08 15:29:18 +02:00
|
|
|
|
2015-04-26 11:22:29 +02:00
|
|
|
(define dependencies
|
2018-08-08 15:29:18 +02:00
|
|
|
(map (lambda (name)
|
|
|
|
(list name (list 'unquote (string->symbol name))))
|
|
|
|
(map hackage-name->package-name
|
|
|
|
hackage-dependencies)))
|
2018-07-13 15:54:41 +02:00
|
|
|
|
|
|
|
(define native-dependencies
|
2018-08-08 15:29:18 +02:00
|
|
|
(map (lambda (name)
|
|
|
|
(list name (list 'unquote (string->symbol name))))
|
|
|
|
(map hackage-name->package-name
|
|
|
|
hackage-native-dependencies)))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
|
|
|
(define (maybe-inputs input-type inputs)
|
|
|
|
(match inputs
|
|
|
|
(()
|
|
|
|
'())
|
|
|
|
((inputs ...)
|
|
|
|
(list (list input-type
|
|
|
|
(list 'quasiquote inputs))))))
|
|
|
|
|
2015-04-26 11:22:29 +02:00
|
|
|
(define (maybe-arguments)
|
2019-06-13 21:39:14 +02:00
|
|
|
(match (append (if (not include-test-dependencies?)
|
|
|
|
'(#:tests? #f)
|
|
|
|
'())
|
|
|
|
(if (not (string-null? revision))
|
|
|
|
`(#:cabal-revision (,revision ,cabal-hash))
|
|
|
|
'()))
|
|
|
|
(() '())
|
|
|
|
(args `((arguments (,'quasiquote ,args))))))
|
2015-04-26 11:22:29 +02:00
|
|
|
|
2015-03-08 07:48:38 +01:00
|
|
|
(let ((tarball (with-store store
|
|
|
|
(download-to-store store source-url))))
|
2018-08-08 15:29:18 +02:00
|
|
|
(values
|
|
|
|
`(package
|
|
|
|
(name ,(hackage-name->package-name name))
|
|
|
|
(version ,version)
|
|
|
|
(source (origin
|
|
|
|
(method url-fetch)
|
|
|
|
(uri (string-append ,@(factorize-uri source-url version)))
|
|
|
|
(sha256
|
|
|
|
(base32
|
|
|
|
,(if tarball
|
|
|
|
(bytevector->nix-base32-string (file-sha256 tarball))
|
|
|
|
"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))
|
|
|
|
(description ,(cabal-package-description cabal))
|
|
|
|
(license ,(string->license (cabal-package-license cabal))))
|
|
|
|
(append hackage-dependencies hackage-native-dependencies))))
|
2015-04-26 11:22:29 +02:00
|
|
|
|
2019-05-26 23:18:21 +02:00
|
|
|
(define* (hackage->guix-package package-name #:key
|
|
|
|
(include-test-dependencies? #t)
|
|
|
|
(port #f)
|
|
|
|
(cabal-environment '()))
|
|
|
|
"Fetch the Cabal file for PACKAGE-NAME from hackage.haskell.org, or, if the
|
2015-04-26 11:22:29 +02:00
|
|
|
called with keyword parameter PORT, from PORT. Return the `package'
|
|
|
|
S-expression corresponding to that package, or #f on failure.
|
|
|
|
CABAL-ENVIRONMENT is an alist defining the environment in which the Cabal
|
|
|
|
conditionals are evaluated. The accepted keys are: \"os\", \"arch\", \"impl\"
|
|
|
|
and the name of a flag. The value associated with a flag has to be either the
|
|
|
|
symbol 'true' or 'false'. The value associated with other keys has to conform
|
|
|
|
to the Cabal file format definition. The default value associated with the
|
|
|
|
keys \"os\", \"arch\" and \"impl\" is \"linux\", \"x86_64\" and \"ghc\"
|
|
|
|
respectively."
|
2019-06-13 21:39:14 +02:00
|
|
|
(let-values (((cabal-meta cabal-hash)
|
|
|
|
(if port
|
|
|
|
(read-cabal-and-hash port)
|
|
|
|
(hackage-fetch-and-hash package-name))))
|
|
|
|
(and=> cabal-meta (compose (cut hackage-module->sexp <> cabal-hash
|
2019-05-26 23:18:21 +02:00
|
|
|
#:include-test-dependencies?
|
|
|
|
include-test-dependencies?)
|
|
|
|
(cut eval-cabal <> cabal-environment)))))
|
|
|
|
|
|
|
|
(define hackage->guix-package/m ;memoized variant
|
|
|
|
(memoize hackage->guix-package))
|
2018-08-08 15:29:18 +02:00
|
|
|
|
|
|
|
(define* (hackage-recursive-import package-name . args)
|
|
|
|
(recursive-import package-name #f
|
|
|
|
#:repo->guix-package (lambda (name repo)
|
2019-05-26 23:18:21 +02:00
|
|
|
(apply hackage->guix-package/m
|
|
|
|
(cons name args)))
|
2018-08-08 15:29:18 +02:00
|
|
|
#:guix-name hackage-name->package-name))
|
2015-03-08 07:48:38 +01:00
|
|
|
|
2016-03-23 04:44:51 +01:00
|
|
|
(define (hackage-package? package)
|
|
|
|
"Return #t if PACKAGE is a Haskell package from Hackage."
|
|
|
|
|
|
|
|
(define haskell-url?
|
|
|
|
(let ((hackage-rx (make-regexp "https?://hackage.haskell.org")))
|
|
|
|
(lambda (url)
|
|
|
|
(regexp-exec hackage-rx url))))
|
|
|
|
|
|
|
|
(let ((source-url (and=> (package-source package) origin-uri))
|
|
|
|
(fetch-method (and=> (package-source package) origin-method)))
|
|
|
|
(and (eq? fetch-method url-fetch)
|
|
|
|
(match source-url
|
|
|
|
((? string?)
|
|
|
|
(haskell-url? source-url))
|
|
|
|
((source-url ...)
|
|
|
|
(any haskell-url? source-url))))))
|
|
|
|
|
2016-04-14 21:40:20 +02:00
|
|
|
(define (latest-release package)
|
|
|
|
"Return an <upstream-source> for the latest release of PACKAGE."
|
|
|
|
(let* ((hackage-name (guix-package->hackage-name package))
|
2016-03-23 04:44:51 +01:00
|
|
|
(cabal-meta (hackage-fetch hackage-name)))
|
|
|
|
(match cabal-meta
|
|
|
|
(#f
|
|
|
|
(format (current-error-port)
|
|
|
|
"warning: failed to parse ~a~%"
|
|
|
|
(hackage-cabal-url hackage-name))
|
|
|
|
#f)
|
|
|
|
((_ *** ("version" (version)))
|
|
|
|
(let ((url (hackage-source-url hackage-name version)))
|
|
|
|
(upstream-source
|
2016-04-14 21:40:20 +02:00
|
|
|
(package (package-name package))
|
2016-03-23 04:44:51 +01:00
|
|
|
(version version)
|
|
|
|
(urls (list url))))))))
|
|
|
|
|
|
|
|
(define %hackage-updater
|
|
|
|
(upstream-updater
|
|
|
|
(name 'hackage)
|
|
|
|
(description "Updater for Hackage packages")
|
|
|
|
(pred hackage-package?)
|
|
|
|
(latest latest-release)))
|
|
|
|
|
2015-03-08 07:48:38 +01:00
|
|
|
;;; cabal.scm ends here
|