guix build: '-f' accepts file-like objects.
* guix/scripts/build.scm (options->things-to-build)[validate-type]: Check for 'file-like?'. (options->derivations): Accept 'file-like?'. * tests/guix-build.sh: Add a test with 'computed-file'. * doc/guix.texi (Additional Build Options): Mention file-like objects.
This commit is contained in:
parent
64965a068d
commit
b33e191c86
|
@ -6365,9 +6365,8 @@ retrieved using the @option{--log-file} option.
|
||||||
|
|
||||||
@item --file=@var{file}
|
@item --file=@var{file}
|
||||||
@itemx -f @var{file}
|
@itemx -f @var{file}
|
||||||
|
Build the package, derivation, or other file-like object that the code within
|
||||||
Build the package or derivation that the code within @var{file}
|
@var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
|
||||||
evaluates to.
|
|
||||||
|
|
||||||
As an example, @var{file} might contain a package definition like this
|
As an example, @var{file} might contain a package definition like this
|
||||||
(@pxref{Defining Packages}):
|
(@pxref{Defining Packages}):
|
||||||
|
|
|
@ -623,7 +623,7 @@ must be one of 'package', 'all', or 'transitive'~%")
|
||||||
"Read the arguments from OPTS and return a list of high-level objects to
|
"Read the arguments from OPTS and return a list of high-level objects to
|
||||||
build---packages, gexps, derivations, and so on."
|
build---packages, gexps, derivations, and so on."
|
||||||
(define (validate-type x)
|
(define (validate-type x)
|
||||||
(unless (or (package? x) (derivation? x) (gexp? x) (procedure? x))
|
(unless (or (derivation? x) (file-like? x) (gexp? x) (procedure? x))
|
||||||
(leave (G_ "~s: not something we can build~%") x)))
|
(leave (G_ "~s: not something we can build~%") x)))
|
||||||
|
|
||||||
(define (ensure-list x)
|
(define (ensure-list x)
|
||||||
|
@ -700,6 +700,10 @@ package '~a' has no source~%")
|
||||||
(set-guile-for-build (default-guile))
|
(set-guile-for-build (default-guile))
|
||||||
(proc))
|
(proc))
|
||||||
#:system system)))
|
#:system system)))
|
||||||
|
((? file-like? obj)
|
||||||
|
(list (run-with-store store
|
||||||
|
(lower-object obj system
|
||||||
|
#:target (assoc-ref opts 'target)))))
|
||||||
((? gexp? gexp)
|
((? gexp? gexp)
|
||||||
(list (run-with-store store
|
(list (run-with-store store
|
||||||
(mbegin %store-monad
|
(mbegin %store-monad
|
||||||
|
|
|
@ -221,6 +221,10 @@ guix build -e "(begin
|
||||||
guix build -e '#~(mkdir #$output)' -d
|
guix build -e '#~(mkdir #$output)' -d
|
||||||
guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
|
guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
|
||||||
|
|
||||||
|
# Same with a file-like object.
|
||||||
|
guix build -e '(computed-file "foo" #~(mkdir #$output))' -d
|
||||||
|
guix build -e '(computed-file "foo" #~(mkdir #$output))' -d | grep 'foo\.drv'
|
||||||
|
|
||||||
# Building from a package file.
|
# Building from a package file.
|
||||||
cat > "$module_dir/package.scm"<<EOF
|
cat > "$module_dir/package.scm"<<EOF
|
||||||
(use-modules (gnu))
|
(use-modules (gnu))
|
||||||
|
|
Loading…
Reference in New Issue