[PATCH] guix: Improve docstring of wrap-program.

  • Open
  • quality assurance status badge
Details
2 participants
  • Brendan Tildesley
  • Christopher Baines
Owner
unassigned
Submitted by
Brendan Tildesley
Severity
minor
B
B
Brendan Tildesley wrote on 1 Apr 2020 07:29
(address . guix-patches@gnu.org)
20200401052949.23868-1-mail@brendan.scot
* guix/build/utils.scm (wrap-progran): Add an explanation for POSITION. Change
'DIRECTORIES' to 'VALUES' since an environment variable might not only be
paths.'
---
guix/build/utils.scm | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

Toggle diff (39 lines)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index b8be73ead4..ba4d1d8657 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1114,13 +1115,20 @@ known as `nuke-refs' in Nixpkgs."
(string-suffix? "-real" base)))))
(define* (wrap-program prog #:rest vars)
- "Make a wrapper for PROG. VARS should look like this:
+ "Make a wrapper for PROG. VARS is a list of lists that should look like this:
- '(VARIABLE DELIMITER POSITION LIST-OF-DIRECTORIES)
+ '(VARIABLE DELIMITER POSITION LIST-OF-VALUES)
where DELIMITER is optional. ':' will be used if DELIMITER is not given.
-
-For example, this command:
+POSITION is a Scheme symbol of either =, prefix, or suffix that selects how
+the export VARIABLE line is formatted. prefix and suffix each result in
+including values from the users environment either after or before VALUE,
+whereas = overshadows any existing value, preventing the users environment
+from 'infecting' the wrapped programs environment. It is important to
+understand how each variable is used by the program so that the correct choice
+can be made. Otherwise, the program could malfunction in unexpected ways on a
+different persons computer due to a difference in the inherited environment
+variables. For example, this command:
(wrap-program \"foo\"
'(\"PATH\" \":\" = (\"/gnu/.../bar/bin\"))
--
2.26.0
C
C
Christopher Baines wrote on 21 Nov 2020 11:17
(name . Brendan Tildesley)(address . mail@brendan.scot)(address . 40365@debbugs.gnu.org)
87eeknhv3j.fsf@cbaines.net
Brendan Tildesley <mail@brendan.scot> writes:

Toggle quote (7 lines)
> * guix/build/utils.scm (wrap-progran): Add an explanation for POSITION. Change
> 'DIRECTORIES' to 'VALUES' since an environment variable might not only be
> paths.'
> ---
> guix/build/utils.scm | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)

Thanks Brendan, and apologies that it's taken a while to review this.

I made some tweaks to end up with this:

(define* (wrap-program prog #:rest vars)
- "Make a wrapper for PROG. VARS should look like this:
+ "Make a wrapper for PROG. VARS is a list of lists that should look like this:

- '(VARIABLE DELIMITER POSITION LIST-OF-DIRECTORIES)
+ '(VARIABLE DELIMITER POSITION LIST-OF-VALUES)

where DELIMITER is optional. ':' will be used if DELIMITER is not given.

+POSITION is a symbol, either =, prefix, or suffix that selects how the
+LIST-OF-VALUES are consolidated with the value of VARIABLE at the time the
+wrapped program is run. prefix and suffix each result in including values
+from the users environment either before or after LIST-OF-VALUES respectively,
+whereas = replaces any existing value for VARIABLE. It is important to
+understand how each variable is used by the program so that the correct choice
+can be made.
+

I'll hopefully describe why below. Anyway, let me know what you think,
I'm happy to push some improvements to this.

There's a bit of a cost to updating this file, since I believe changing
it will effectively trigger every Guix package's derivation to change,
hence it will need to be done on the core-updates branch.

Toggle quote (19 lines)
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index b8be73ead4..ba4d1d8657 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -5,6 +5,7 @@
> ;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org>
> ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
> ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
> +;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -1114,13 +1115,20 @@ known as `nuke-refs' in Nixpkgs."
> (string-suffix? "-real" base)))))
>
> (define* (wrap-program prog #:rest vars)
> - "Make a wrapper for PROG. VARS should look like this:
> + "Make a wrapper for PROG. VARS is a list of lists that should look like this:

I'm not sure I'd describe vars as a list of lists, I think I see what
you're getting at, in that there can be more than one thing in vars, but
from the perspective of a user of this procedure, you don't pass in a
list of list, just one or more arguments at the end.

Toggle quote (10 lines)
>
> - '(VARIABLE DELIMITER POSITION LIST-OF-DIRECTORIES)
> + '(VARIABLE DELIMITER POSITION LIST-OF-VALUES)
>
> where DELIMITER is optional. ':' will be used if DELIMITER is not given.
> -
> -For example, this command:
> +POSITION is a Scheme symbol of either =, prefix, or suffix that selects how
> +the export VARIABLE line is formatted. prefix and suffix each result in

Rather than talking about formatting here, I tried to say something
about "consolidation", although maybe that's too complicated.

Toggle quote (8 lines)
> +including values from the users environment either after or before VALUE,
> +whereas = overshadows any existing value, preventing the users environment
> +from 'infecting' the wrapped programs environment. It is important to
> +understand how each variable is used by the program so that the correct choice
> +can be made. Otherwise, the program could malfunction in unexpected ways on a
> +different persons computer due to a difference in the inherited environment
> +variables. For example, this command:

I'm not sure about including this "Otherwise ..." bit, I think what you
say prior is sufficient.

Toggle quote (4 lines)
>
> (wrap-program \"foo\"
> '(\"PATH\" \":\" = (\"/gnu/.../bar/bin\"))

Thanks again,

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+46VBfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XfAOg//Vti+okhqsUpXwwMSy1WXBzleTmRjOlWI
j57Tq/3SJDSt3x8bRAB/YHwO6fUBvePW4rdofalloUCCSuSyGmuQy5inTxYGo0mJ
VdSlaO/OEee6Ri2JUgu7FrXOHMm/KK5ZcFunKjFmN73T3hNGyRVZo4R5zBMaOGh3
yX6ZtP9cj6ppU6eIieweTg/zuX9Ha239SONhLf5piSYVtpznX1Fk5nFuGr+dmXUD
nCvK76pb7jrMAV0YNHZP+h7h3irpJ5KXuUrj120I9rzPgVn8bHGDXjPMIQRGDovF
glIGQt4X+IHUTgSpkBT+IQDn1DfVsBQ/LapwAsA0mqcftTrlW831RY7MxXxKAjkH
5ETlRsgoSlMH+FSPj6gBw0GHLaQb0aps5VbhdCzLv1o9FXAd5WVJ6Kg4YhEOyP/P
bQs/ZElk54RVD9lB4gyUBobJ617G73Xud2sa4635GweDtvrUvC6dT8J/3nda8WG9
oirpRGxI0y6eMjqti7mrckeJEy7ulurkkTfQOkvFJDPzTMtgxD00KwMUeMSm/8q1
4bi4wSqdoT5huenLeL3Lag1rDS1tOFwZj4afv310qSXKZkUOf3ooWOq5AQkdiNK+
gGPRLopl02obJ/7brwJ2DyP19YNscQwJm5Hrn/JkcDQAZuhM0ErAaE+WOLz4lY34
SLYewyvBCj0=
=G9Uq
-----END PGP SIGNATURE-----

?