Subject: bug#73073: closed (Re: [bug#73073] [PATCH v3 0/8] Support lookups of origins used as package inputs)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 15 Dec 2024 23:29:02 +0000

Your bug report

#73073: [PATCH 0/6] Allow origin with label as inputs.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
73073: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73073
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#73073] [PATCH v3 0/8] Support lookups of origins used as package inputs
From: Ludovic Courtès <[email-masked]>
To: [email-masked]
Date: Mon, 16 Dec 2024 00:28:12 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

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

> This is v3 of the patch series submitted by Simon, rebased
> on current ‘master’.
>
> The main change is the removal of special-casing from (guix
> packages), as suggested before, and the addition of a test.
>
> It passes “the LibreOffice test” (no world rebuild).
>
> Objetions?

Pushed as 79f8769530cc78297b2443856984b2b1338caa3c.

However, I had to drop the ‘git’ change because in the meantime it has
gained several thousand dependents (see
<https://issues.guix.gnu.org/74892>.)

I also fixed the “libgd-checkout” issue in ‘gnome-recipes’.

Last, I added a few words in the manual (commit
f8f005815efdf9f0d5d2a5ac30c6fdd19aa22e72).

Thanks,
Ludo’.

Subject: [PATCH 0/6] Allow origin with label as inputs.
From: Simon Tournier <[email-masked]>
To: [email-masked]
Cc: Simon Tournier <[email-masked]>
Date: Fri, 6 Sep 2024 17:51:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

As discussed in bug#73034 [1], these 5 packages – farstream,
gnulib-checkout, smithforth, gnome-recipes and dmd-bootstrap – have an
origin inside the ’arguments’ package record.

This is annoying because these origins are hidden from
’package-direct-sources’; see module (guix packages).

I consider this is bug. :-)  Hence this prposal for fixing it.

Moreover and tangentially, it appears to me an anti-pattern of the
functional paradigm: The data from the impure outside should be handled
by the ’source’ record field, or otherwise by ’inputs’, ’native-inputs’
or ’propagated-inputs’ record fields; let say only ’inputs’ for
simplicity.

To my knowledge, using the old style with label, we strove on this
principle.  However, using the “new style” [2], it does not offer to
have labels with plain package symbol.  In other words, for example,
this snippet does not work:

      (list gdmd which
            `("phobos"
              ,(origin
                 (method git-fetch)
                 (uri (git-reference
                       (url "https://github.com/dlang/phobos")
                       (commit (string-append "v" version))))
                 (file-name (git-file-name "phobos" version))
                 (sha256
                  (base32
                   "1yw7nb5d78cx9m7sfibv7rfc7wj3w0dw9mfk3d269qpfpnwzs4n9"))))))

The reason is because ’sanitize-inputs’; see module (guix packages).

    ((_ (list args ...))
     (add-input-labels args ...))
    ((_ inputs)
     (maybe-add-input-labels inputs))))

Roughly speaking, because the ’inputs’ starts by the term ’list’ then
’add-input-labels’ is applied, else it applies ’maybe-add-input-labels’.

Note that:

    (define (add-input-labels . inputs)
      "Add labels to all of INPUTS if needed (this is the rest-argument version of
    'maybe-add-input-labels')."
      (maybe-add-input-labels inputs))

The procedure ’maybe-add-input-labels’ reads: if the first element of
the ’inputs’ record field is using the “old style“ then return all
as-is, assuming all are “old style”.  Else apply to all the ’inputs’
elements the procedure ’add-input-label’.

Hence the simple proposal:

--8<---------------cut here---------------start------------->8---
diff --git a/guix/packages.scm b/guix/packages.scm
index f373136d22..5fea44c2bb 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -676,6 +676,8 @@ (define (add-input-label input)
               "_")
          ,obj
          ,@(if (string=? output "out") '() (list output)))))
+    (((? string? label) obj) ;Allow old style as sometimes requires by origin in inputs
+     `(,label ,obj))
     (x
      `("_" ,x))))
--8<---------------cut here---------------end--------------->8---

This allows to write ’inputs’ as above. :-)  As done with the 5 packages.

And it does not hurt the new style.  Maybe “guix style” would need to be
adjusted too?

WDYT?

Cheers,
simon

1: [bug#73034] [PATCH v3 0/3] Fix annoyances of Git and update to 2.46.0
Maxim Cournoyer <[email-masked]>
Fri, 06 Sep 2024 13:17:33 +0900
id:[email-masked]
https://issues.guix.gnu.org/73034
https://issues.guix.gnu.org/msgid/[email-masked]
https://yhetil.org/guix/[email-masked]

2: https://guix.gnu.org/en/blog/2021/the-big-change/

Simon Tournier (6):
  guix: packages: Allow origin with label as inputs.
  gnu: dmd-bootstrap: Move phobos origin from phases to native-inputs.
  gnu: smithforth: Move system.fs origin from phases to native-inputs.
  gnu: gnome-recipes: Move libgd origin from phases to native-inputs.
  gnu: farstream: Move common origin from phases to native-inputs.
  gnu: gnulib: Move phobos origin from phases to native-inputs.

 gnu/packages/build-tools.scm | 18 ++++++++++--------
 gnu/packages/dlang.scm       | 22 ++++++++++++----------
 gnu/packages/forth.scm       | 20 +++++++++++---------
 gnu/packages/freedesktop.scm | 24 +++++++++++++-----------
 gnu/packages/gnome.scm       | 22 ++++++++++++----------
 guix/packages.scm            |  2 ++
 6 files changed, 60 insertions(+), 48 deletions(-)

base-commit: 7d2ced8d6d9c38327592d312376d59a8c37fc160
-- 
2.45.2