Subject: bug#58567: Some grafts use a different input derivation than computed by --no-grafts

From: Marius Bakke <[email-masked]>
Date: Mon, 17 Oct 2022 13:36:21 +0200

zimoun <[email-masked]> skriver:

> Hi Marius,
>
> I reminds me this [1].
>
> 1: <https://yhetil.org/guix/[email-masked]>

Not sure if it's the same problem, but it is weird.  On 3d8c243efb615c7:

  $ guix build mesa
  /gnu/store/ccf705wvh0w224d6nyscnwlhqr04agk7-mesa-21.3.8-bin
  /gnu/store/vcmxgmmhwr39gwwnz7ljkhcg1bmq2r5z-mesa-21.3.8
  $ guix build --no-grafts mesa
  /gnu/store/grh2142hg6l5g5xav2di7rr1pwbg9m38-mesa-21.3.8-bin
  /gnu/store/sdzfljm6san79pqiy42yp0nzmkr2bafc-mesa-21.3.8
  $ guix size icecat | grep mesa
  /gnu/store/sdzfljm6san79pqiy42yp0nzmkr2bafc-mesa-21.3.8            411.6   169.6  11.6%
  $ guix size $(guix build --no-grafts icecat) | grep mesa
  /gnu/store/sdzfljm6san79pqiy42yp0nzmkr2bafc-mesa-21.3.8            411.6   169.6  11.6%

Should not the mesa used by icecat be the same as `guix build mesa`,
just like in the ungrafted case?  Their outputs differ, too:

  $ guix hash -r $(guix build mesa | tail -n1)
  1invy9jcd1fnfx7d4asfyjqs1jn7lngjfqswak6sy9ffjbhhsg6x
  $ guix hash -r $(guix size icecat | grep mesa | awk '{ print $1 }')
  195zk0c0h5m016hp0c1haqws47rwfj7sbpqpddmwk2iw402p3apv

Diffoscope says it will take 123 days to process these, so don't hold
your breath!

> On dim., 16 oct. 2022 at 19:35, Marius Bakke <[email-masked]> wrote:
>
>> It works for 'python-patiencediff', but fails for 'python-patch-ng',
>> both of which have no dependencies other than Python; but one uses
>> url-fetch and the other git-fetch.
>
> I guess that
>
>    guix build python-patch-ng -d
>
> uses a grafted git-minimal and propagates it, whereas
>
>    guix build python-patch-ng -d --no-grafts
>
> uses a non-grafted git-minimal.  Well, something like that. :-)

Indeed.

> Well, it is the same checkout output:
>
> --8<---------------cut here---------------start------------->8---
> $ guix build \
>    /gnu/store/7bcypqy80bz8ygi4880dxdj8vzcsvhdf-python-patch-ng-1.17.4-checkout.drv \
>    /gnu/store/ivbkmnl6md7lzf275nvqwdh6lc924hal-python-patch-ng-1.17.4-checkout.drv
> /gnu/store/jddbmm7nxhv9sl84j1jlsdy5iiwjpbiy-python-patch-ng-1.17.4-checkout
> /gnu/store/jddbmm7nxhv9sl84j1jlsdy5iiwjpbiy-python-patch-ng-1.17.4-checkout
> --8<---------------cut here---------------end--------------->8---

That's guaranteed since these derivations are "fixed-output" (notice the
r:sha256 property in the beginning of the file).  If they had any other
output the daemon would throw a failure.

The bug here is that Guix treats grafted origins as different, even
though their outputs are known in advance.

Probably the grafting machinery should ignore fixed-output derivations
somehow?