[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#70895] [PATCH] grafts: Only compute necessary graft derivations.
From: |
David Elsing |
Subject: |
[bug#70895] [PATCH] grafts: Only compute necessary graft derivations. |
Date: |
Wed, 05 Jun 2024 21:43:16 +0000 |
Ludovic Courtès <ludo@gnu.org> writes:
Hi Ludo',
> While this does the job, it breaks an abstraction (grafts are
> lower-level than packages) and creates a circular dependency between
> (guix grafts) and (guix packages) as a result (not technically a problem
> at this point, but it shows that something’s deserves to be clarified).
>
> Maybe there’s a simpler way to achieve this though. What about allowing
> monadic values in the ‘origin’ and ‘replacement’ fields of <graft>?
> Their values would be bound lazily, only when needed by
> ‘graft-derivation’.
Yes, that's a good idea, this makes the patch a lot shorter as well.
The 'origin' field need to computed anyway to check whether the graft is
applicable, so only the 'replacement' field needs to be bound lazily.
In cumulative-grafts, I check whether the replacement field is a monadic
value using 'procedure?' and then call 'run-with-store'. Is there a
better way to do this? I see that values in the %state-monad are
repesented as plain lambdas. Also, is it correct to set the
#:guile-for-build and #:system keyword arguments here, as they are
already specified in package->derivation and package->cross-derivation?
As an alternative, is it possible to 'ungexp' a value in the store monad
which returns a derivation? Then the derivation for the 'replacement'
field could be calculated in 'mapping' in 'graft-derivation/shallow'.
I wouldn't know how to define a gexp-compiler though, except by defining
one for any procedure and assuming it is a value in the store monad.
Cheers,
David