From 39f4ef59ffc37259de40f67c476a1a720aa8d007 Mon Sep 17 00:00:00 2001 From: Xinglu Chen Date: Tue, 2 Nov 2021 17:48:09 +0100 Subject: [PATCH] =?UTF-8?q?build-system:=20haskell:=20Add=20=E2=80=98hacka?= =?UTF-8?q?ge-uri=E2=80=99=20procedure.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- guix/build-system/haskell.scm | 11 ++++++++++- guix/import/hackage.scm | 5 +++-- 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 18a584f78258bad1bf6f1ff6ffbdd26634ca10fa..72e37f2b0e925b7cd0ed98a883b1d780a7f8628b 100644 --- a/guix/build-system/haskell.scm +++ b/guix/build-system/haskell.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2020 Timothy Sample ;;; Copyright © 2020 Simon Tournier +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,7 +31,9 @@ #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) - #:export (%haskell-build-system-modules + #:export (hackage-uri + + %haskell-build-system-modules haskell-build haskell-build-system)) @@ -41,6 +44,12 @@ ;; ;; Code: +(define (hackage-uri name version) + "Return a URI string for the Haskell package hosted on Hackage corresponding +to NAME and VERSION." + (string-append "https://hackage.haskell.org/package/" name "/" + name "-" version ".tar.gz")) + (define %haskell-build-system-modules ;; Build-side modules imported by default. `((guix build haskell-build-system) diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 03881f1a3d577cd347d5722b6d552382dcbfd4b9..0d5616ca627d6860631c62d732ad438057df3c21 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -40,6 +40,7 @@ #:use-module (guix memoization) #:use-module (guix upstream) #:use-module (guix packages) + #:autoload (guix build-system haskell) (hackage-uri) #:use-module ((guix utils) #:select (call-with-temporary-output-file)) #:export (%hackage-url hackage->guix-package @@ -303,7 +304,7 @@ the hash of the Cabal file." (version ,version) (source (origin (method url-fetch) - (uri (string-append ,@(factorize-uri source-url version))) + (uri (hackage-uri ,name version)) (sha256 (base32 ,(if tarball @@ -367,7 +368,7 @@ respectively." (hackage-cabal-url hackage-name)) #f) ((_ *** ("version" (version))) - (let ((url (hackage-source-url hackage-name version))) + (let ((url (hackage-uri hackage-name version))) (upstream-source (package (package-name package)) (version version) diff --git a/tests/hackage.scm b/tests/hackage.scm index aca807027cc4763991c79db5c2c53b090f8de379..ba694661f3fd36918bbfdf02cef0b8cd32f4ff54 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -170,10 +170,7 @@ library ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -215,10 +212,7 @@ library ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -343,10 +337,7 @@ executable cabal ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -409,10 +400,7 @@ executable cabal ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash)))))