Subject: [bug#70895] [PATCH] grafts: Only compute necessary graft derivations.

From: David Elsing <[email-masked]>
Date: Wed, 29 Jan 2025 19:30:59 +0000

Hi,

Ludovic Courtès <[email-masked]> writes:

> My thought was that the fact that grafts must be enabled on the
> replacement, etc., are implementation details.  I’d like producers of
> <graft> records to just be able to drop whatever is relevant to them in
> the ‘replacement’ field.

Ah sure, that makes sense to me.

> Let me know if you notice something wrong.

I noticed that 'with-parameters' doesn't actually do anything here. :)
The 'graft-origin' is already a derivation anyway, so there it has
obviously no effect. For the 'graft-replacement', I noticed that when
setting %graft? to #f, it still results in the same grafted derivation.
The same was the case in my version using 'with-parameters' in
'input-graft' of course.

I also wanted to use 'with-parameters' for the ROCm packages, but found
that it generally does not work for packages [1], this seems to be also
the case here.
IIUC, this is because 'lower-object' returns a monadic procedure, which
is evaluated outside the influence of 'with-fluids' in the gexp-compiler
of <parameterized>.

The grafting still works correctly however, I think because the %graft?
parameter is also set when the derivations are actually calculated,
while in 'input-graft', 'package->derivation' is explicitely called with
#:graft? set to #f.

What do you think?

Best,
David

[1] https://issues.guix.gnu.org/75879