The version of the package, as a string.
@item @code{source}
-An origin object telling how the source code for the package should be
-acquired (@pxref{origin Reference}).
+An object telling how the source code for the package should be
+acquired. Most of the time, this is an @code{origin} object, which
+denotes a file fetched from the Internet (@pxref{origin Reference}). It
+can also be any other ``file-like'' object such as a @code{local-file},
+which denotes a file from the local file system (@pxref{G-Expressions,
+@code{local-file}}).
@item @code{build-system}
The build system that should be used to build the package (@pxref{Build
;; store path, it needs to be added anyway, so it can be used as a
;; source.
(list name (intern file)))
- (((? string? name) (? origin? source))
+ (((? string? name) (? struct? source))
(list name (package-source-derivation store source system)))
(x
(raise (condition (&package-input-error
(origin->derivation origin system))
(define package-source-derivation ;somewhat deprecated
- (let ((lower (store-lower origin->derivation)))
+ (let ((lower (store-lower lower-object)))
(lambda* (store source #:optional (system (%current-system)))
"Return the derivation or file corresponding to SOURCE, which can be an
-<origin> or a file name. When SOURCE is a file name, return either the
-interned file name (if SOURCE is outside of the store) or SOURCE itself (if
-SOURCE is already a store item.)"
+a file name or any object handled by 'lower-object', such as an <origin>.
+When SOURCE is a file name, return either the interned file name (if SOURCE is
+outside of the store) or SOURCE itself (if SOURCE is already a store item.)"
(match source
((and (? string?) (? direct-store-path?) file)
file)
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix grafts)
+ #:use-module ((guix gexp) #:select (local-file local-file-file))
#:use-module ((guix utils)
;; Rename the 'location' binding to allow proper syntax
;; matching when setting the 'location' field of a package.
(and (direct-store-path? source)
(string-suffix? "utils.scm" source))))
+(test-assert "package-source-derivation, local-file"
+ (let* ((file (local-file "../guix/base32.scm"))
+ (package (package (inherit (dummy-package "p"))
+ (source file)))
+ (source (package-source-derivation %store
+ (package-source package))))
+ (and (store-path? source)
+ (string-suffix? "base32.scm" source)
+ (valid-path? %store source)
+ (equal? (call-with-input-file source get-bytevector-all)
+ (call-with-input-file
+ (search-path %load-path "guix/base32.scm")
+ get-bytevector-all)))))
+
(unless (network-reachable?) (test-skip 1))
(test-equal "package-source-derivation, snippet"
"OK"