[DRAFT PATCH core-updates] build-systems: Pass #:allowed-references and #:disallowed-references to builders.

  • Open
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Marius Bakke
  • Maxime Devos
Owner
unassigned
Submitted by
Marius Bakke
Severity
normal
M
M
Marius Bakke wrote on 10 Sep 2022 17:26
(address . guix-patches@gnu.org)
20220910152604.3459-1-marius@gnu.org
* guix/build-system/gnu.scm (gnu-build, gnu-cross-build)[builder]: Pass
along #:allowed-references and #:disallowed-references.
* guix/build-system/meson.scm (meson-build, meson-cross-build)[builder]: Likewise.
---
Hello Guix,

This is an untested patch that makes #:allowed-references
and #:disallowed-references available to build-side code.

The intention is to make it easier to use these properties directly when
e.g. wrapping. Consider the following:

Toggle snippet (18 lines)
(arguments
(list
#:disallowed-references (list (gexp-input glib "bin")
(gexp-input inkscape/stable))
#:phases
#~(modify-phases %standard-phases
(replace 'glib-or-gtk-wrap
(let ((wrap (assoc-ref %standard-phases 'glib-or-gtk-wrap)))
(lambda* (#:key inputs outputs disallowed-references
#:allow-other-keys)
(wrap #:inputs (filter (match-lambda
((label . output)
(not (member output
disallowed-references))))
inputs)
#:outputs outputs)))))))

This way we don't have to build the list of disallowed references twice,
which is difficult without labels in the case of e.g. `(,glib "bin").

Note: I implemented a variant of this approach using a let-binding in
f0114656876dcf2e09874e4ea0c00cacf31f1bb2, perhaps that is "good enough"
as this approach is unlikely to be much used.

WDYT? I'll implement this for the remaining build systems if this is at
all sane.
---


Toggle diff (46 lines)
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index 8eea1cd4c2..f85a172153 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -393,6 +393,8 @@ (define builder
#:build #$build
#:outputs %outputs
#:inputs %build-inputs
+ #:allowed-references #$allowed-references
+ #:disallowed-references #$disallowed-references
#:search-paths '#$(sexp->gexp
(map search-path-specification->sexp
search-paths))
@@ -531,6 +533,8 @@ (define %outputs
#:target #$target
#:outputs %outputs
#:inputs %build-target-inputs
+ #:allowed-references #$allowed-references
+ #:disallowed-references #$disallowed-references
#:native-inputs %build-host-inputs
#:search-paths '#$(sexp->gexp
(map search-path-specification->sexp
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index 9fee6c4570..1bef07230f 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -210,6 +210,8 @@ (define build-phases
#$(with-build-variables inputs outputs
#~(meson-build #:source #+source
#:system #$system
+ #:allowed-references #$allowed-references
+ #:disallowed-references #$disallowed-references
#:outputs %outputs
#:inputs %build-inputs
#:search-paths '#$(sexp->gexp
@@ -318,6 +320,8 @@ (define build-phases
#:system #$system
#:build #$(nix-system->gnu-triplet system)
#:target #$target
+ #:allowed-references #$allowed-references
+ #:disallowed-references #$disallowed-references
#:outputs #$(outputs->gexp outputs)
#:inputs #$inputs
#:native-inputs #+(input-tuples->gexp build-inputs)
--
2.37.3
M
M
Maxime Devos wrote on 10 Sep 2022 18:27
(name . Ludovic Courtès)(address . ludo@gnu.org)
b08daa5d-0726-4a90-2fb1-c96eec1f130b@telenet.be
On 10-09-2022 17:26, Marius Bakke wrote:
Toggle quote (9 lines)
> This way we don't have to build the list of disallowed references twice,
> which is difficult without labels in the case of e.g. `(,glib "bin").
>
> Note: I implemented a variant of this approach using a let-binding in
> f0114656876dcf2e09874e4ea0c00cacf31f1bb2, perhaps that is "good enough"
> as this approach is unlikely to be much used.
>
> WDYT? I'll implement this for the remaining build systems if this is at
> all sane.
A caveat with using #:disallowed-references this way -- AFAIK, it is
undocumented whether #:disallowed-references goes for a native build or
a cross-build. The intention is to stop the (natively-)compiled
python-some-testing-library from appearing in the wrappers, stopping a
cross-compiled python-some-testing-library.
Depending on what, exactly, the behaviour of #:disallowed-references is,
it may be necessary to ‘override’ whether to disallow the native- or the
cross-version.
To do so, I used 'gexp-input' with #:native? #true in (gnu packages
glib) (maybe that was unnecessary, but I was thinking better be explicit
than implicit here ...).
An alternative solution could be to split #:disallowed-reference in two,
e.g. #:disallowed-references/system and #:disallowed-references/target,
to prevent accidents.
Greetings,
Maxime.
Attachment: OpenPGP_signature
M
M
Maxime Devos wrote on 10 Sep 2022 18:32
(name . Ludovic Courtès)(address . ludo@gnu.org)
0e685c25-bbd1-13e0-799f-0fa78044e6c4@telenet.be
On 10-09-2022 17:26, Marius Bakke wrote:
Toggle quote (2 lines)
> + #:allowed-references #$allowed-references
> + #:disallowed-references #$disallowed-references
Unless I'm mistaken (I haven't tested this), this will become
#:allowed-references ("/gnu/store/..." ...) -- it tries to use a string
as a procedure. Proposal:
#:allowed-references (list #$allowed-references)
#:disallowed-references (list #$disallowed-references)
Greetings,
Maxime.
Attachment: OpenPGP_signature
M
M
Maxime Devos wrote on 10 Sep 2022 18:34
(name . Ludovic Courtès)(address . ludo@gnu.org)
0ee62f18-2449-6fc8-fbc2-7c897975edaa@telenet.be
On 10-09-2022 18:32, Maxime Devos wrote:
Toggle quote (13 lines)
>
>
> On 10-09-2022 17:26, Marius Bakke wrote:
>> +                           #:allowed-references #$allowed-references
>> +                           #:disallowed-references
>> #$disallowed-references
>
> Unless I'm mistaken (I haven't tested this), this will become
> #:allowed-references ("/gnu/store/..." ...) -- it tries to use a string
> as a procedure.  Proposal:
>
> #:allowed-references (list #$allowed-references)
> #:disallowed-references (list #$disallowed-references)
Correction:
#:allowed-references
#$(and=> allowed-references (lambda (x) #~(list #$@x)))
#:disallowed-references
(list #$@disallowed-references)
(splicing, and allowed-reference is by default #false)
Toggle quote (2 lines)
> Greetings,
> Maxime.
Attachment: OpenPGP_signature
L
L
Ludovic Courtès wrote on 11 Sep 2022 16:12
(name . Marius Bakke)(address . marius@gnu.org)(address . 57717@debbugs.gnu.org)
87bkrmyp7n.fsf@gnu.org
Hi,

Marius Bakke <marius@gnu.org> skribis:

Toggle quote (33 lines)
> * guix/build-system/gnu.scm (gnu-build, gnu-cross-build)[builder]: Pass
> along #:allowed-references and #:disallowed-references.
> * guix/build-system/meson.scm (meson-build, meson-cross-build)[builder]: Likewise.
> ---
> Hello Guix,
>
> This is an untested patch that makes #:allowed-references
> and #:disallowed-references available to build-side code.
>
> The intention is to make it easier to use these properties directly when
> e.g. wrapping. Consider the following:
>
> (arguments
> (list
> #:disallowed-references (list (gexp-input glib "bin")
> (gexp-input inkscape/stable))
> #:phases
> #~(modify-phases %standard-phases
> (replace 'glib-or-gtk-wrap
> (let ((wrap (assoc-ref %standard-phases 'glib-or-gtk-wrap)))
> (lambda* (#:key inputs outputs disallowed-references
> #:allow-other-keys)
> (wrap #:inputs (filter (match-lambda
> ((label . output)
> (not (member output
> disallowed-references))))
> inputs)
> #:outputs outputs)))))))
>
>
> This way we don't have to build the list of disallowed references twice,
> which is difficult without labels in the case of e.g. `(,glib "bin").

Why not.

The only possible drawback I can think of is that it could hide errors:
since things listed in #:disallowed-references are automatically removed
from wrappers, you could end up successfully building a wrapper that
lacks items without noticing. But yeah, maybe that’s a questionable
scenario.

Toggle quote (3 lines)
> + #:allowed-references #$allowed-references
> + #:disallowed-references #$disallowed-references

Maxime raised a good point on this one, but I think you can write:

#:disallowed-references '#$disallowed-references

This will work whether ‘disallowed-references’ is #f or a list.

Thanks!

Ludo’.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 57717@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 57717
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch