diff options
| author | Xinglu Chen <public@yoctocell.xyz> | 2021-11-02 17:48:09 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2021-12-01 17:53:25 +0100 |
| commit | 39f4ef59ffc37259de40f67c476a1a720aa8d007 (patch) | |
| tree | e390543a1aae3f1233cc6795f95d9173488406aa | |
| parent | a955e4d7f6843bd7dc804ea69ccdef953f4780bc (diff) | |
build-system: haskell: Add ‘hackage-uri’ procedure.
* guix/build-system/haskell (hackage-uri): New procedure.
* guix/import/hackage.scm (hackage-module->sexp, latest-release): Use it.
* tests/hackage.scm (match-ghc-foo, match-ghc-foo-6, match-ghc-foo-revision,
match-ghc-foo-import): Adjust accordingly.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
| -rw-r--r-- | guix/build-system/haskell.scm | 11 | ||||
| -rw-r--r-- | guix/import/hackage.scm | 5 | ||||
| -rw-r--r-- | tests/hackage.scm | 20 |
3 files changed, 17 insertions, 19 deletions
diff --git a/guix/build-system/haskell.scm b/guix/build-system/haskell.scm index 18a584f7825..72e37f2b0e9 100644 --- a/guix/build-system/haskell.scm +++ b/guix/build-system/haskell.scm | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> | 2 | ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> |
| 3 | ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> | 3 | ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> |
| 4 | ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> | 4 | ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> |
| 5 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> | ||
| 5 | ;;; | 6 | ;;; |
| 6 | ;;; This file is part of GNU Guix. | 7 | ;;; This file is part of GNU Guix. |
| 7 | ;;; | 8 | ;;; |
| @@ -30,7 +31,9 @@ | |||
| 30 | #:use-module (ice-9 match) | 31 | #:use-module (ice-9 match) |
| 31 | #:use-module (srfi srfi-1) | 32 | #:use-module (srfi srfi-1) |
| 32 | #:use-module (srfi srfi-26) | 33 | #:use-module (srfi srfi-26) |
| 33 | #:export (%haskell-build-system-modules | 34 | #:export (hackage-uri |
| 35 | |||
| 36 | %haskell-build-system-modules | ||
| 34 | haskell-build | 37 | haskell-build |
| 35 | haskell-build-system)) | 38 | haskell-build-system)) |
| 36 | 39 | ||
| @@ -41,6 +44,12 @@ | |||
| 41 | ;; | 44 | ;; |
| 42 | ;; Code: | 45 | ;; Code: |
| 43 | 46 | ||
| 47 | (define (hackage-uri name version) | ||
| 48 | "Return a URI string for the Haskell package hosted on Hackage corresponding | ||
| 49 | to NAME and VERSION." | ||
| 50 | (string-append "https://hackage.haskell.org/package/" name "/" | ||
| 51 | name "-" version ".tar.gz")) | ||
| 52 | |||
| 44 | (define %haskell-build-system-modules | 53 | (define %haskell-build-system-modules |
| 45 | ;; Build-side modules imported by default. | 54 | ;; Build-side modules imported by default. |
| 46 | `((guix build haskell-build-system) | 55 | `((guix build haskell-build-system) |
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 03881f1a3d5..0d5616ca627 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #:use-module (guix memoization) | 40 | #:use-module (guix memoization) |
| 41 | #:use-module (guix upstream) | 41 | #:use-module (guix upstream) |
| 42 | #:use-module (guix packages) | 42 | #:use-module (guix packages) |
| 43 | #:autoload (guix build-system haskell) (hackage-uri) | ||
| 43 | #:use-module ((guix utils) #:select (call-with-temporary-output-file)) | 44 | #:use-module ((guix utils) #:select (call-with-temporary-output-file)) |
| 44 | #:export (%hackage-url | 45 | #:export (%hackage-url |
| 45 | hackage->guix-package | 46 | hackage->guix-package |
| @@ -303,7 +304,7 @@ the hash of the Cabal file." | |||
| 303 | (version ,version) | 304 | (version ,version) |
| 304 | (source (origin | 305 | (source (origin |
| 305 | (method url-fetch) | 306 | (method url-fetch) |
| 306 | (uri (string-append ,@(factorize-uri source-url version))) | 307 | (uri (hackage-uri ,name version)) |
| 307 | (sha256 | 308 | (sha256 |
| 308 | (base32 | 309 | (base32 |
| 309 | ,(if tarball | 310 | ,(if tarball |
| @@ -367,7 +368,7 @@ respectively." | |||
| 367 | (hackage-cabal-url hackage-name)) | 368 | (hackage-cabal-url hackage-name)) |
| 368 | #f) | 369 | #f) |
| 369 | ((_ *** ("version" (version))) | 370 | ((_ *** ("version" (version))) |
| 370 | (let ((url (hackage-source-url hackage-name version))) | 371 | (let ((url (hackage-uri hackage-name version))) |
| 371 | (upstream-source | 372 | (upstream-source |
| 372 | (package (package-name package)) | 373 | (package (package-name package)) |
| 373 | (version version) | 374 | (version version) |
diff --git a/tests/hackage.scm b/tests/hackage.scm index aca807027cc..ba694661f3f 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm | |||
| @@ -170,10 +170,7 @@ library | |||
| 170 | ('source | 170 | ('source |
| 171 | ('origin | 171 | ('origin |
| 172 | ('method 'url-fetch) | 172 | ('method 'url-fetch) |
| 173 | ('uri ('string-append | 173 | ('uri ('hackage-uri "foo" 'version)) |
| 174 | "https://hackage.haskell.org/package/foo/foo-" | ||
| 175 | 'version | ||
| 176 | ".tar.gz")) | ||
| 177 | ('sha256 | 174 | ('sha256 |
| 178 | ('base32 | 175 | ('base32 |
| 179 | (? string? hash))))) | 176 | (? string? hash))))) |
| @@ -215,10 +212,7 @@ library | |||
| 215 | ('source | 212 | ('source |
| 216 | ('origin | 213 | ('origin |
| 217 | ('method 'url-fetch) | 214 | ('method 'url-fetch) |
| 218 | ('uri ('string-append | 215 | ('uri ('hackage-uri "foo" 'version)) |
| 219 | "https://hackage.haskell.org/package/foo/foo-" | ||
| 220 | 'version | ||
| 221 | ".tar.gz")) | ||
| 222 | ('sha256 | 216 | ('sha256 |
| 223 | ('base32 | 217 | ('base32 |
| 224 | (? string? hash))))) | 218 | (? string? hash))))) |
| @@ -343,10 +337,7 @@ executable cabal | |||
| 343 | ('source | 337 | ('source |
| 344 | ('origin | 338 | ('origin |
| 345 | ('method 'url-fetch) | 339 | ('method 'url-fetch) |
| 346 | ('uri ('string-append | 340 | ('uri ('hackage-uri "foo" 'version)) |
| 347 | "https://hackage.haskell.org/package/foo/foo-" | ||
| 348 | 'version | ||
| 349 | ".tar.gz")) | ||
| 350 | ('sha256 | 341 | ('sha256 |
| 351 | ('base32 | 342 | ('base32 |
| 352 | (? string? hash))))) | 343 | (? string? hash))))) |
| @@ -409,10 +400,7 @@ executable cabal | |||
| 409 | ('source | 400 | ('source |
| 410 | ('origin | 401 | ('origin |
| 411 | ('method 'url-fetch) | 402 | ('method 'url-fetch) |
| 412 | ('uri ('string-append | 403 | ('uri ('hackage-uri "foo" 'version)) |
| 413 | "https://hackage.haskell.org/package/foo/foo-" | ||
| 414 | 'version | ||
| 415 | ".tar.gz")) | ||
| 416 | ('sha256 | 404 | ('sha256 |
| 417 | ('base32 | 405 | ('base32 |
| 418 | (? string? hash))))) | 406 | (? string? hash))))) |
