2017-02-06 12:19:26 -05:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
|
;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
|
2018-08-20 11:38:56 -04:00
|
|
|
|
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
|
2020-02-04 07:18:18 -05:00
|
|
|
|
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
|
2021-09-16 07:29:42 -04:00
|
|
|
|
;;; Copyright © 2021 Xinglu Chem <public@yoctocell.xyz>
|
2023-01-03 11:11:10 -05:00
|
|
|
|
;;; Copyright © 2021, 2023, 2023 Ludovic Courtès <ludo@gnu.org>
|
2022-06-24 16:01:35 -04:00
|
|
|
|
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
|
2017-02-06 12:19:26 -05: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 stackage)
|
|
|
|
|
#:use-module (ice-9 match)
|
2021-09-30 16:38:57 -04:00
|
|
|
|
#:use-module (json)
|
2017-02-06 12:19:26 -05:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2017-02-11 12:18:45 -05:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-35)
|
2017-02-06 12:19:26 -05:00
|
|
|
|
#:use-module (guix import json)
|
|
|
|
|
#:use-module (guix import hackage)
|
upstream: Replace 'input-changes' field by 'inputs'.
Returning the expected list of inputs rather than changes relative to
the current package definition is less ambiguous and offers more
possibilities for further processing.
* guix/upstream.scm (<upstream-source>)[input-changes]: Remove.
[inputs]: New field.
(<upstream-input>): New record type.
* guix/upstream.scm (upstream-input-type-predicate)
(input-type-filter, upstream-source-regular-inputs)
(upstream-source-native-inputs, upstream-source-propagated-inputs): New
procedures.
(changed-inputs): Expect an <upstream-source> as its second argument.
Adjust accordingly.
* guix/import/pypi.scm (distribution-sha256): New procedure.
(maybe-inputs): Expect a list of <upstream-input>.
(compute-inputs): Rewrite to return a list of <upstream-input>.
(pypi-package-inputs, pypi-package->upstream-source): New procedures.
(make-pypi-sexp): Use it.
* guix/import/stackage.scm (latest-lts-release): Define 'cabal'.
Replace 'input-changes' field by 'inputs'.
* guix/scripts/refresh.scm (update-package): Use 'changed-inputs'
instead of 'upstream-source-input-changes'.
* tests/cran.scm ("description->package"): Adjust order of inputs.
* tests/pypi.scm (default-sha256, default-sha256/base32): New variables.
(foo-json): Add 'digests' entry.
("pypi->guix-package, no wheel"): Check HASH against DEFAULT-SHA256/BASE32.
("pypi->guix-package, wheels"): Likewise.
("pypi->guix-package, no usable requirement file."): Likewise.
("pypi->guix-package, package name contains \"-\" followed by digits"):
Likewise.
("package-latest-release"): New test.
* tests/upstream.scm (test-package-sexp): Remove.
("changed-inputs returns no changes"): Rewrite to use <upstream-source>.
(test-new-package-sexp): Remove.
("changed-inputs returns changes to plain input list"): Rewrite.
("changed-inputs returns changes to all plain input lists"): Likewise.
("changed-inputs returns changes to labelled input list")
("changed-inputs returns changes to all labelled input lists"): Remove.
* guix/import/cran.scm (maybe-inputs): Expect PACKAGE-INPUTS to be a
list of <upstream-input>.
(source-dir->dependencies): Return a list of <upstream-input>.
(vignette-builders): Likewise.
(uri-helper, cran-package-source-url)
(cran-package-propagated-inputs, cran-package-inputs): New procedures.
(description->package): Use them instead of local definitions.
(latest-cran-release): Replace 'input-changes' field by 'inputs'.
(latest-bioconductor-release): Likewise.
(format-inputs): Remove.
* guix/import/hackage.scm (cabal-package-inputs): New procedure.
(hackage-module->sexp): Use it.
[maybe-inputs]: Expect a list of <upstream-input>.
2023-05-15 16:37:25 -04:00
|
|
|
|
#:autoload (guix import cabal) (eval-cabal)
|
2018-08-20 11:38:56 -04:00
|
|
|
|
#:use-module (guix import utils)
|
2017-02-06 12:19:26 -05:00
|
|
|
|
#:use-module (guix memoization)
|
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (guix upstream)
|
2021-09-30 16:50:55 -04:00
|
|
|
|
#:use-module (guix diagnostics)
|
|
|
|
|
#:use-module (guix i18n)
|
2020-11-03 15:30:28 -05:00
|
|
|
|
#:export (%stackage-url
|
|
|
|
|
stackage->guix-package
|
2018-08-20 11:38:56 -04:00
|
|
|
|
stackage-recursive-import
|
2017-02-06 12:19:26 -05:00
|
|
|
|
%stackage-updater))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Stackage info fetcher and access functions
|
|
|
|
|
;;;
|
|
|
|
|
|
2020-11-03 15:30:28 -05:00
|
|
|
|
(define %stackage-url
|
|
|
|
|
(make-parameter "https://www.stackage.org"))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
2021-09-14 05:43:37 -04:00
|
|
|
|
;; Latest LTS version compatible with current GHC.
|
2022-05-08 07:55:07 -04:00
|
|
|
|
(define %default-lts-version "20.5")
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(define-json-mapping <stackage-lts> make-stackage-lts
|
|
|
|
|
stackage-lts?
|
|
|
|
|
json->stackage-lts
|
|
|
|
|
(snapshot stackage-lts-snapshot "snapshot" json->snapshot)
|
|
|
|
|
(packages stackage-lts-packages "packages"
|
|
|
|
|
(lambda (vector)
|
|
|
|
|
(map json->stackage-package (vector->list vector)))))
|
|
|
|
|
|
|
|
|
|
(define-json-mapping <snapshot> make-snapshot
|
|
|
|
|
stackage-snapshot?
|
|
|
|
|
json->snapshot
|
|
|
|
|
(name snapshot-name)
|
|
|
|
|
(ghc-version snapshot-ghc-version)
|
|
|
|
|
(compiler snapshot-compiler))
|
|
|
|
|
|
|
|
|
|
(define-json-mapping <stackage-package> make-stackage-package
|
|
|
|
|
stackage-package?
|
|
|
|
|
json->stackage-package
|
|
|
|
|
(origin stackage-package-origin)
|
|
|
|
|
(name stackage-package-name)
|
|
|
|
|
(version stackage-package-version)
|
|
|
|
|
(synopsis stackage-package-synopsis))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
|
|
|
|
(define stackage-lts-info-fetch
|
|
|
|
|
;; "Retrieve the information about the LTS Stackage release VERSION."
|
|
|
|
|
(memoize
|
|
|
|
|
(lambda* (#:optional (version ""))
|
2020-11-03 15:30:28 -05:00
|
|
|
|
(let* ((url (string-append (%stackage-url)
|
2019-07-16 09:41:23 -04:00
|
|
|
|
"/lts-" (if (string-null? version)
|
|
|
|
|
%default-lts-version
|
|
|
|
|
version)))
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(lts-info (and=> (json-fetch url) json->stackage-lts)))
|
|
|
|
|
(or lts-info
|
2021-09-30 16:50:55 -04:00
|
|
|
|
(raise (formatted-message (G_ "LTS release version not found: ~a")
|
|
|
|
|
version)))))))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(define (lts-package-version packages name)
|
|
|
|
|
"Return the version of the package with upstream NAME included in PACKAGES."
|
2017-02-06 12:19:26 -05:00
|
|
|
|
(let ((pkg (find (lambda (pkg) (string=? (stackage-package-name pkg) name))
|
2021-09-30 16:38:57 -04:00
|
|
|
|
packages)))
|
2023-12-02 12:23:05 -05:00
|
|
|
|
(and=> pkg stackage-package-version)))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Importer entry point
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (hackage-name-version name version)
|
|
|
|
|
(and version (string-append name "@" version)))
|
|
|
|
|
|
2018-08-20 11:38:56 -04:00
|
|
|
|
(define stackage->guix-package
|
|
|
|
|
(memoize
|
|
|
|
|
(lambda* (package-name ; upstream name
|
|
|
|
|
#:key
|
|
|
|
|
(include-test-dependencies? #t)
|
2019-07-16 09:41:23 -04:00
|
|
|
|
(lts-version %default-lts-version)
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(packages
|
|
|
|
|
(stackage-lts-packages
|
2022-11-27 05:12:32 -05:00
|
|
|
|
(stackage-lts-info-fetch lts-version)))
|
|
|
|
|
#:allow-other-keys)
|
2018-08-20 11:38:56 -04:00
|
|
|
|
"Fetch Cabal file for PACKAGE-NAME from hackage.haskell.org. The retrieved
|
2019-09-23 15:04:36 -04:00
|
|
|
|
version corresponds to the version of PACKAGE-NAME specified in the LTS-VERSION
|
2017-02-06 12:19:26 -05:00
|
|
|
|
release at stackage.org. Return the `package' S-expression corresponding to
|
|
|
|
|
that package, or #f on failure. PACKAGES-INFO is the alist with the packages
|
|
|
|
|
included in the Stackage LTS release."
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(let* ((version (lts-package-version packages package-name))
|
2018-08-20 11:38:56 -04:00
|
|
|
|
(name-version (hackage-name-version package-name version)))
|
|
|
|
|
(if name-version
|
|
|
|
|
(hackage->guix-package name-version
|
|
|
|
|
#:include-test-dependencies?
|
|
|
|
|
include-test-dependencies?)
|
2021-09-30 16:50:55 -04:00
|
|
|
|
(raise (formatted-message (G_ "~a: Stackage package not found")
|
|
|
|
|
package-name)))))))
|
2018-08-20 11:38:56 -04:00
|
|
|
|
|
|
|
|
|
(define (stackage-recursive-import package-name . args)
|
2020-02-04 07:18:18 -05:00
|
|
|
|
(recursive-import package-name
|
2022-11-27 05:12:32 -05:00
|
|
|
|
#:repo->guix-package (lambda* (name #:key version #:allow-other-keys)
|
2018-08-20 11:38:56 -04:00
|
|
|
|
(apply stackage->guix-package (cons name args)))
|
|
|
|
|
#:guix-name hackage-name->package-name))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Updater
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define latest-lts-release
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(let ((packages
|
|
|
|
|
(mlambda ()
|
|
|
|
|
(stackage-lts-packages
|
|
|
|
|
(stackage-lts-info-fetch %default-lts-version)))))
|
2022-06-24 16:01:35 -04:00
|
|
|
|
(lambda* (pkg #:key (version #f))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
"Return an <upstream-source> for the latest Stackage LTS release of
|
2020-06-09 16:29:38 -04:00
|
|
|
|
PACKAGE or #f if the package is not included in the Stackage LTS release."
|
2022-06-24 16:01:35 -04:00
|
|
|
|
(when version
|
2023-04-07 12:11:21 -04:00
|
|
|
|
(raise
|
2022-06-24 16:01:35 -04:00
|
|
|
|
(formatted-message
|
|
|
|
|
(G_ "~a updater doesn't support updating to a specific version, sorry.")
|
|
|
|
|
"stackage")))
|
2023-01-04 03:37:26 -05:00
|
|
|
|
(let* ((hackage-name (package-upstream-name* pkg))
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(version (lts-package-version (packages) hackage-name))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
(name-version (hackage-name-version hackage-name version)))
|
|
|
|
|
(match (and=> name-version hackage-fetch)
|
2021-09-30 16:50:55 -04:00
|
|
|
|
(#f
|
|
|
|
|
(warning (G_ "failed to parse ~a~%")
|
|
|
|
|
(hackage-cabal-url hackage-name))
|
|
|
|
|
#f)
|
2023-06-09 05:46:05 -04:00
|
|
|
|
(_ (let ((url (hackage-source-url hackage-name version)))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
(upstream-source
|
2021-09-16 02:12:17 -04:00
|
|
|
|
(package (package-name pkg))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
(version version)
|
2021-09-16 02:12:17 -04:00
|
|
|
|
(urls (list url))
|
2023-06-09 05:46:05 -04:00
|
|
|
|
(inputs
|
|
|
|
|
(let ((cabal (eval-cabal (hackage-fetch name-version) '())))
|
|
|
|
|
(cabal-package-inputs cabal)))))))))))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(define (stackage-lts-package? package)
|
|
|
|
|
"Return whether PACKAGE is available on the default Stackage LTS release."
|
2021-09-16 07:29:42 -04:00
|
|
|
|
(and (hackage-package? package)
|
2023-01-03 11:11:10 -05:00
|
|
|
|
(false-if-networking-error
|
|
|
|
|
(let ((packages (stackage-lts-packages
|
|
|
|
|
(stackage-lts-info-fetch %default-lts-version)))
|
2023-01-04 03:37:26 -05:00
|
|
|
|
(hackage-name (package-upstream-name* package)))
|
2023-01-03 11:11:10 -05:00
|
|
|
|
(find (lambda (package)
|
|
|
|
|
(string=? (stackage-package-name package) hackage-name))
|
|
|
|
|
packages)))))
|
2021-09-16 07:29:42 -04:00
|
|
|
|
|
2017-02-06 12:19:26 -05:00
|
|
|
|
(define %stackage-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'stackage)
|
|
|
|
|
(description "Updater for Stackage LTS packages")
|
2021-09-30 16:38:57 -04:00
|
|
|
|
(pred stackage-lts-package?)
|
upstream-updater: Rename record field.
The next commits will make the functions, which are currently importing the
latest version of a package, change into importing the latest or a given
version of the package (for those updaters supporting specifying a version).
Thus the name ‘latest‘ is no longer appropriate.
* guix/upstream.scm (upstream-updater) Rename field [latest] to
[import]. (lookup-updater, package-latest-release) Adjust fieldname
accordingly.
* guix/gnu-maintenance.scm (%gnu-updater, %gnu-ftp-updater,
%savannah-updater, %sourceforge-updater, %xorg-updater,
%kernel.org-updater, %generic-html-updater),
guix/import/cpan.scm (%cpan-updater),
guix/import/cran.scm (%cran-updater, %bioconductor-updater),
guix/import/crate.scm (%crate-updater),
guix/import/egg.scm (%egg-updater),
guix/import/elpa.scm (%elpa-updater),
guix/import/gem.scm (%gem-updater),
guix/import/git.scm (%generic-git-updater),
guix/import/github.scm (%github-updater),
guix/import/gnome.scm (%gnome-updater),
guix/import/hackage.scm (%hackage-updater),
guix/import/hexpm.scm (%hexpm-updater),
guix/import/kde.scm (%kde-updater),
guix/import/launchpad.scm (%launchpad-updater),
guix/import/minetest.scm (%minetest-updater),
guix/import/opam.scm (%opam-updater),
guix/import/pypi.scm (%pypi-updater),
guix/import/stackage.scm (%stackage-updater),
tests/import-github.scm (found-sexp)
tests/transformations.scm ("options->transformation, with-latest"):
Adjust fieldname accordingly.
2022-08-27 07:05:33 -04:00
|
|
|
|
(import latest-lts-release)))
|
2017-02-06 12:19:26 -05:00
|
|
|
|
|
|
|
|
|
;;; stackage.scm ends here
|