guix_mirror_bot pushed a commit to branch master
in repository guix.

commit b3a2b7cbe5113e36880a20738a4b148969e93005
Author: Ludovic Courtès <[email protected]>
AuthorDate: Tue Oct 6 15:23:48 2026 +0200

    shell: Allow for caching when ‘-e’ is used.
    
    * guix/scripts/shell.scm (options-with-caching): On cache hit, remove
    ‘expression’ entries from ‘opts’.
    (profile-cached-gc-root): Change 'expression case to allow for caching.
    
    Fixes: guix/guix#10697
    Reported-by: Nigko Yerden <[email protected]>
    Signed-off-by: Ludovic Courtès <[email protected]>
    Merges: #11684
---
 guix/scripts/shell.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index 32d46fee55d..81f04537365 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -257,6 +257,7 @@ cache) or a 'gc-root' key (to add the profile to cache)."
                                 (('manifest . _) #t)
                                 (('package . _) #t)
                                 (('ad-hoc-package . _) #t)
+                                (('expression . _) #t)
                                 (_ #f))
                               opts)))             ;load right away
         (if (and root (not (assq-ref opts 'gc-root)))
@@ -401,10 +402,10 @@ return #f and #f."
        (loop rest system
              (max mtime (stat:mtime (stat candidate)))
              (cons `(manifest ,candidate) specs)))
-      ((('expression . _) . _)
-       ;; Arbitrary expressions might be non-deterministic or otherwise depend
-       ;; on external state so do not cache when they're used.
-       (values #f #f))
+      ((('expression . exp) . rest)
+       ;; Assume that EXP is deterministic and that the result can be cached.
+       ;; In practice EXP typically refers to a package variable in a module.
+       (loop rest system mtime (cons `(expression ,exp) specs)))
       ((((? transformation-option-key? key) . _) . rest)
        ;; Transformation options are potentially "non-deterministic", or at
        ;; least depending on external state (with-source, with-commit, etc.).

Reply via email to