[Top][All Lists]

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

02/04: derivations: Avoid another call to 'read-derivation-from-file'.

From: guix-commits
Subject: 02/04: derivations: Avoid another call to 'read-derivation-from-file'.
Date: Wed, 3 Jul 2019 17:45:34 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit c14a2b289d2dd2fc2240e8ae226fadfa957fc587
Author: Ludovic Court├Ęs <address@hidden>
Date:   Wed Jul 3 22:36:56 2019 +0200

    derivations: Avoid another call to 'read-derivation-from-file'.
    This is a followup to 5cf4b26d52bcea382d98fb4becce89be9ee37b55.
    * guix/derivations.scm (derivation-path->base16-hash): Rename to...
    (derivation-base16-hash): ... this, and take a <derivation> rather than
    a file name.  Use 'mlambdaq' instead of 'mlambda'.
    (derivation/masked-inputs): Adjust accordingly.
    (invalidate-derivation-caches!): Likewise.
 guix/derivations.scm | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index 4e969cb..8ce96ce 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -652,12 +652,10 @@ list of name/path pairs of its outputs."
 ;;; Derivation primitive.
-(define derivation-path->base16-hash
-  (mlambda (file)
-    "Return a string containing the base16 representation of the hash of the
-derivation at FILE."
-    (bytevector->base16-string
-     (derivation-hash (read-derivation-from-file file)))))
+(define derivation-base16-hash
+  (mlambdaq (drv)
+    "Return a string containing the base16 representation of the hash of DRV."
+    (bytevector->base16-string (derivation-hash drv))))
 (define (derivation/masked-inputs drv)
   "Assuming DRV is a regular derivation (not fixed-output), replace the file
@@ -666,9 +664,8 @@ name of each input with that input's hash."
     (($ <derivation> outputs inputs sources
                      system builder args env-vars)
      (let ((inputs (map (match-lambda
-                          (($ <derivation-input> (= derivation-file-name path)
-                                                 sub-drvs)
-                           (let ((hash (derivation-path->base16-hash path)))
+                          (($ <derivation-input> drv sub-drvs)
+                           (let ((hash (derivation-base16-hash drv)))
                              (make-derivation-input hash sub-drvs))))
        (make-derivation outputs
@@ -886,7 +883,7 @@ long-running processes that know what they're doing.  Use 
with care!"
   ;; Typically this is meant to be used by Cuirass and Hydra, which can clear
   ;; caches when they start evaluating packages for another architecture.
   (invalidate-memoization! derivation->bytevector)
-  (invalidate-memoization! derivation-path->base16-hash)
+  (invalidate-memoization! derivation-base16-hash)
   ;; FIXME: Comment out to work around <>.
   ;; (hash-clear! %derivation-cache)

reply via email to

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