guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/06: guix build: '-f' accepts file-like objects.


From: Ludovic Courtès
Subject: 06/06: guix build: '-f' accepts file-like objects.
Date: Tue, 9 Oct 2018 12:54:29 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit b33e191c86b7638517ea838b63a54d031a033554
Author: Ludovic Courtès <address@hidden>
Date:   Tue Oct 9 18:52:37 2018 +0200

    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.
---
 doc/guix.texi          | 5 ++---
 guix/scripts/build.scm | 6 +++++-
 tests/guix-build.sh    | 4 ++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3c116fc..9b37270 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -6365,9 +6365,8 @@ retrieved using the @option{--log-file} option.
 
 @item address@hidden
 @itemx -f @var{file}
-
-Build the package or derivation that the code within @var{file}
-evaluates to.
+Build the package, derivation, or other file-like object that the code within
address@hidden evaluates to (@pxref{G-Expressions, file-like objects}).
 
 As an example, @var{file} might contain a package definition like this
 (@pxref{Defining Packages}):
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 5a6ba62..f3aa551 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -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
 build---packages, gexps, derivations, and so on."
   (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)))
 
   (define (ensure-list x)
@@ -700,6 +700,10 @@ package '~a' has no source~%")
                               (set-guile-for-build (default-guile))
                               (proc))
                             #:system system)))
+                   ((? file-like? obj)
+                    (list (run-with-store store
+                            (lower-object obj system
+                                          #:target (assoc-ref opts 'target)))))
                    ((? gexp? gexp)
                     (list (run-with-store store
                             (mbegin %store-monad
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 92e7299..7842ce8 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -221,6 +221,10 @@ guix build -e "(begin
 guix build -e '#~(mkdir #$output)' -d
 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.
 cat > "$module_dir/package.scm"<<EOF
 (use-modules (gnu))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]