summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-10-29 21:51:39 +0200
committerLudovic Courtès <ludo@gnu.org>2021-11-11 00:14:31 +0100
commit04d929570ad816793d7e0024a11314124ce87f98 (patch)
tree735825ce00192b1dd14376dd43d98a1e06664c79 /guix/import
parent450e1dd52e0a34bb00fcb655956e40d69d50a331 (diff)
import: print: Properly render packages with origins as inputs.
* guix/import/print.scm (package->code)[source->code]: Check whether VERSION is true before calling 'factorize-uri'. [package-lists->code]: Add clause for inputs that are origins. * tests/print.scm (pkg-with-origin-input, pkg-with-origin-input-source): New variables. ("package with origin input"): New test.
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/print.scm14
1 files changed, 9 insertions, 5 deletions
diff --git a/guix/import/print.scm b/guix/import/print.scm
index 0310739b3a..8acf5d52f6 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -89,9 +89,11 @@ when evaluated."
(guix hg-download)
(guix svn-download)))
(procedure-name method)))
- (uri (string-append ,@(match (factorize-uri uri version)
- ((? string? uri) (list uri))
- (factorized factorized))))
+ (uri ,(if version
+ `(string-append ,@(match (factorize-uri uri version)
+ ((? string? uri) (list uri))
+ (factorized factorized)))
+ uri))
,(if (equal? (content-hash-algorithm hash) 'sha256)
`(sha256 (base32 ,(bytevector->nix-base32-string
(content-hash-value hash))))
@@ -109,7 +111,7 @@ when evaluated."
(map (match-lambda
((? symbol? s)
(list (symbol->string s) (list 'unquote s)))
- ((label pkg . out)
+ ((label (? package? pkg) . out)
(let ((mod (package-module-name pkg)))
(cons* label
;; FIXME: using '@ certainly isn't pretty, but it
@@ -117,7 +119,9 @@ when evaluated."
;; modules.
(list 'unquote
(list '@ mod (variable-name pkg mod)))
- out))))
+ out)))
+ ((label (? origin? origin))
+ (list label (list 'unquote (source->code origin #f)))))
lsts)))
(let ((name (package-name package))