diff --git a/guix/store.scm b/guix/store.scm index 8fa16499f8..52940ff751 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -1783,6 +1783,9 @@ (define %guile-for-build ;; when using 'gexp->derivation' and co. (make-parameter #f)) +(define set-store-connection-object-cache! + (record-modifier 'object-cache)) + (define* (run-with-store store mval #:key (guile-for-build (%guile-for-build)) @@ -1798,9 +1801,12 @@ (define* (run-with-store store mval (%current-target-system target)) (call-with-values (lambda () (run-with-state mval store)) - (lambda (result store) - ;; Discard the state. - result)))) + (lambda (result new-store) + ;; Copy the object cache from NEW-STORE so we don't fully discard the + ;; state. + (let ((cache (store-connection-object-cache new-store))) + (set-store-connection-object-cache! store cache) + result))))) ;;;