(address . guix-patches@gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
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
(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:
Toggle snippet (14 lines)
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))))
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 <maxim.cournoyer@gmail.com>
Fri, 06 Sep 2024 13:17:33 +0900
id:87msklct5u.fsf@gmail.com
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