aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/scripts/shell.scm13
-rw-r--r--guix/transformations.scm20
2 files changed, 27 insertions, 6 deletions
diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index 0584a7e018..d23362a15d 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2021-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -25,6 +25,7 @@
show-native-build-options-help)
#:autoload (guix transformations) (options->transformation
transformation-option-key?
+ cacheable-transformation-option-key?
show-transformation-options-help)
#:autoload (guix grafts) (%graft?)
#:use-module (guix scripts)
@@ -417,11 +418,13 @@ return #f and #f."
;; Arbitrary expressions might be non-deterministic or otherwise depend
;; on external state so do not cache when they're used.
(values #f #f))
- ((((? transformation-option-key?) . _) . _)
+ ((((? transformation-option-key? key) . _) . rest)
;; Transformation options are potentially "non-deterministic", or at
- ;; least depending on external state (with-source, with-commit, etc.),
- ;; so do not cache anything when they're used.
- (values #f #f))
+ ;; least depending on external state (with-source, with-commit, etc.).
+ ;; Cache only those that are known to be "cacheable".
+ (if (cacheable-transformation-option-key? key)
+ (loop rest system file (cons (first opts) specs))
+ (values #f #f)))
((('profile . _) . _)
;; If the user already specified a profile, there's nothing more to
;; cache.
diff --git a/guix/transformations.scm b/guix/transformations.scm
index 582f8a2729..ea8b7a0844 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;; Copyright © 2023 Sarthak Shah <shahsarthakw@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
@@ -63,6 +63,7 @@
show-transformation-options-help
transformation-option-key?
+ cacheable-transformation-option-key?
%transformation-options))
;;; Commentary:
@@ -938,6 +939,16 @@ are replaced by the specified upstream version."
(with-latest . ,transform-package-latest)
(with-version . ,transform-package-version)))
+(define %transformations-with-external-dependencies
+ ;; Subset of options that depend on external resources and that can thus be
+ ;; considered "non-deterministic" and non-cacheable.
+ '(with-source
+ with-branch
+ with-git-url
+ with-patch
+ with-latest
+ with-version))
+
(define (transformation-procedure key)
"Return the transformation procedure associated with KEY, a symbol such as
'with-source', or #f if there is none."
@@ -952,6 +963,13 @@ are replaced by the specified upstream version."
For example, (transformation-option-key? 'with-input) => #t."
(->bool (transformation-procedure key)))
+(define (cacheable-transformation-option-key? key)
+ "Return true if KEY corresponds to a transformation option whose result can
+be cached--i.e., the transformation is deterministic and does not depend on
+external resources."
+ (and (transformation-option-key? key)
+ (not (memq key %transformations-with-external-dependencies))))
+
;;;
;;; Command-line handling.