diff mbox series

[bug#50960,06/10] environment: Skip derivation computation when '--profile' is used.

Message ID 20211002102240.27815-6-ludo@gnu.org
State Accepted
Headers show
Series Add 'guix shell' to subsume 'guix environment' | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Oct. 2, 2021, 10:22 a.m. UTC
* guix/scripts/environment.scm (guix-environment*): Bypass calls to
'package-derivation' and to 'manifest->derivation' when PROFILE is
true.
---
 guix/scripts/environment.scm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

Liliana Marie Prikler Oct. 2, 2021, 11:39 a.m. UTC | #1
Am Samstag, den 02.10.2021, 12:22 +0200 schrieb Ludovic Courtès:
> * guix/scripts/environment.scm (guix-environment*): Bypass calls to
> 'package-derivation' and to 'manifest->derivation' when PROFILE is
> true.
This only affects `guix shell' and not `guix environment', right?  If
not, does the outward behaviour of `guix environment' stay the same
considering this patch and 07/10?  There might be people relying on the
way `guix environment' *currently* works, who would need to be informed
about that change.

Then again, if the following holds
>   If you run ‘guix pull’ and run again ‘guix shell’, it recomputes
>   the environment, as is currently the case with ‘guix environment’.
then the behaviour of guix environment should also be consistent with
what it did before, but with the added cache of guix shell.  Am I
reading this correctly?

Regards,
Liliana
Ludovic Courtès Oct. 2, 2021, 1:46 p.m. UTC | #2
Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

> Am Samstag, den 02.10.2021, 12:22 +0200 schrieb Ludovic Courtès:
>> * guix/scripts/environment.scm (guix-environment*): Bypass calls to
>> 'package-derivation' and to 'manifest->derivation' when PROFILE is
>> true.
> This only affects `guix shell' and not `guix environment', right?

No, it affects ‘guix environment’ (it’s in environment.scm).  It’s an
optimization of ‘guix environment -p’, but its observable behavior is
unchanged; it’s just faster.

> Then again, if the following holds
>>   If you run ‘guix pull’ and run again ‘guix shell’, it recomputes
>>   the environment, as is currently the case with ‘guix environment’.
> then the behaviour of guix environment should also be consistent with
> what it did before, but with the added cache of guix shell.  Am I
> reading this correctly?

The cache itself is only in ‘guix shell’, in the no-argument case:

  https://issues.guix.gnu.org/50960#9

Ludo’.
diff mbox series

Patch

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 77956fc018..32f376fdd2 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -729,18 +729,21 @@  command-line option processing with 'parse-command-line'."
             ;; Use the bootstrap Guile when requested.
             (parameterize ((%graft? (assoc-ref opts 'graft?))
                            (%guile-for-build
-                            (package-derivation
-                             store
-                             (if bootstrap?
-                                 %bootstrap-guile
-                                 (default-guile)))))
+                            (and (or container? (not profile))
+                                 (package-derivation
+                                  store
+                                  (if bootstrap?
+                                      %bootstrap-guile
+                                      (default-guile))))))
               (run-with-store store
                 ;; Containers need a Bourne shell at /bin/sh.
                 (mlet* %store-monad ((bash       (environment-bash container?
                                                                    bootstrap?
                                                                    system))
-                                     (prof-drv   (manifest->derivation
-                                                  manifest system bootstrap?))
+                                     (prof-drv   (if profile
+                                                     (return #f)
+                                                     (manifest->derivation
+                                                      manifest system bootstrap?)))
                                      (profile -> (if profile
                                                      (readlink* profile)
                                                      (derivation->output-path prof-drv)))
@@ -750,9 +753,9 @@  command-line option processing with 'parse-command-line'."
                   ;; --search-paths.  Additionally, we might need to build bash for
                   ;; a container.
                   (mbegin %store-monad
-                    (built-derivations (if (derivation? bash)
-                                           (list prof-drv bash)
-                                           (list prof-drv)))
+                    (built-derivations (append
+                                           (if prof-drv (list prof-drv) '())
+                                           (if (derivation? bash) (list bash) '())))
                     (mwhen gc-root
                       (register-gc-root profile gc-root))