guix-commits
[Top][All Lists]
Advanced

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

01/04: pack: Add "--derivation".


From: guix-commits
Subject: 01/04: pack: Add "--derivation".
Date: Thu, 21 Nov 2019 05:49:09 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit a2e661e95f8ab2fcb7741198234395b367a794c1
Author: Ludovic Courtès <address@hidden>
Date:   Wed Nov 20 09:57:08 2019 +0100

    pack: Add "--derivation".
    
    * guix/scripts/pack.scm (%options, show-help): Add "--derivation".
    (guix-pack): Honor it.
    * tests/guix-pack.sh: Test it.
    * doc/guix.texi (Invoking guix pack): Document it.
---
 doc/guix.texi         |  4 ++++
 guix/scripts/pack.scm | 21 ++++++++++++++++-----
 tests/guix-pack.sh    |  4 ++++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index ea8a878..1f120b0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5253,6 +5253,10 @@ added to it or removed from it after extraction of the 
pack.
 One use case for this is the Guix self-contained binary tarball
 (@pxref{Binary Installation}).
 
+@item --derivation
+@itemx -d
+Print the name of the derivation that builds the pack.
+
 @item --bootstrap
 Use the bootstrap binaries to build the pack.  This option is only
 useful to Guix developers.
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 920d6c0..89b3e38 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -800,6 +800,10 @@ last resort for relocation."
          (option '(#\n "dry-run") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'dry-run? #t (alist-cons 'graft? #f result))))
+         (option '(#\d "derivation") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'derivation-only? #t result)))
+
          (option '(#\f "format") #t #f
                  (lambda (opt name arg result)
                    (alist-cons 'format (string->symbol arg) result)))
@@ -918,6 +922,8 @@ Create a bundle of PACKAGE.\n"))
   -r, --root=FILE        make FILE a symlink to the result, and register it
                          as a garbage collector root"))
   (display (G_ "
+  -d, --derivation       return the derivation of the pack"))
+  (display (G_ "
   -v, --verbosity=LEVEL  use the given verbosity LEVEL"))
   (display (G_ "
       --bootstrap        use the bootstrap binaries to build the pack"))
@@ -1002,6 +1008,7 @@ Create a bundle of PACKAGE.\n"))
                                           (assoc-ref opts 'system)
                                           #:graft? (assoc-ref opts 'graft?))))
           (let* ((dry-run?    (assoc-ref opts 'dry-run?))
+                 (derivation? (assoc-ref opts 'derivation-only?))
                  (relocatable? (assoc-ref opts 'relocatable?))
                  (proot?      (eq? relocatable? 'proot))
                  (manifest    (let ((manifest (manifest-from-args store opts)))
@@ -1070,11 +1077,15 @@ Create a bundle of PACKAGE.\n"))
                                                      #:archiver
                                                      archiver)))
                 (mbegin %store-monad
-                  (show-what-to-build* (list drv)
-                                       #:use-substitutes?
-                                       (assoc-ref opts 'substitutes?)
-                                       #:dry-run? dry-run?)
-                  (munless dry-run?
+                  (munless derivation?
+                    (show-what-to-build* (list drv)
+                                         #:use-substitutes?
+                                         (assoc-ref opts 'substitutes?)
+                                         #:dry-run? dry-run?))
+                  (mwhen derivation?
+                    (return (format #t "~a~%"
+                                    (derivation-file-name drv))))
+                  (munless (or derivation? dry-run?)
                     (built-derivations (list drv))
                     (mwhen gc-root
                       (register-root* (match (derivation->output-paths drv)
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh
index 0feae6d..cf4e4ca 100644
--- a/tests/guix-pack.sh
+++ b/tests/guix-pack.sh
@@ -36,6 +36,10 @@ export GUIX_BUILD_OPTIONS
 test_directory="`mktemp -d`"
 trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
 
+# Compute the derivation of a pack.
+drv="`guix pack coreutils -d --no-grafts`"
+guix gc -R "$drv" | grep "`guix build coreutils -d --no-grafts`"
+
 # Build a tarball with no compression.
 guix pack --compression=none --bootstrap guile-bootstrap
 



reply via email to

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