From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kN4YCmjpuF90OgAA0tVLHw (envelope-from ) for ; Sat, 21 Nov 2020 10:18:16 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iKftBWjpuF+cSQAAB5/wlQ (envelope-from ) for ; Sat, 21 Nov 2020 10:18:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7054F940222 for ; Sat, 21 Nov 2020 10:18:15 +0000 (UTC) Received: from localhost ([::1]:55400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgPyA-0001IZ-3u for larch@yhetil.org; Sat, 21 Nov 2020 05:18:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgPxx-0001I0-UX for guix-patches@gnu.org; Sat, 21 Nov 2020 05:18:01 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kgPxx-0007aw-MX for guix-patches@gnu.org; Sat, 21 Nov 2020 05:18:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kgPxx-0000MO-I7 for guix-patches@gnu.org; Sat, 21 Nov 2020 05:18:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#40365] [PATCH] guix: Improve docstring of wrap-program. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 21 Nov 2020 10:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Brendan Tildesley Cc: 40365@debbugs.gnu.org Received: via spool by 40365-submit@debbugs.gnu.org id=B40365.16059538791376 (code B ref 40365); Sat, 21 Nov 2020 10:18:01 +0000 Received: (at 40365) by debbugs.gnu.org; 21 Nov 2020 10:17:59 +0000 Received: from localhost ([127.0.0.1]:44895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgPxv-0000M8-DF for submit@debbugs.gnu.org; Sat, 21 Nov 2020 05:17:59 -0500 Received: from mira.cbaines.net ([212.71.252.8]:49138) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgPxu-0000Lz-Gc for 40365@debbugs.gnu.org; Sat, 21 Nov 2020 05:17:59 -0500 Received: from localhost (188.28.108.199.threembb.co.uk [188.28.108.199]) by mira.cbaines.net (Postfix) with ESMTPSA id 83B4527BBF5; Sat, 21 Nov 2020 10:17:57 +0000 (GMT) Received: from capella (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id e5188997; Sat, 21 Nov 2020 10:17:55 +0000 (UTC) References: <20200401052949.23868-1-mail@brendan.scot> User-agent: mu4e 1.4.13; emacs 27.1 From: Christopher Baines In-reply-to: <20200401052949.23868-1-mail@brendan.scot> Date: Sat, 21 Nov 2020 10:17:52 +0000 Message-ID: <87eeknhv3j.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.61 X-TUID: deUTD4ONBJzf --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Brendan Tildesley writes: > * guix/build/utils.scm (wrap-progran): Add an explanation for POSITION. C= hange > '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) =2D "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: =2D '(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 =3D, 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 respectiv= ely, +whereas =3D replaces any existing value for VARIABLE. It is important to +understand how each variable is used by the program so that the correct ch= oice +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. > 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 =C2=A9 2015, 2018 Mark H Weaver > ;;; Copyright =C2=A9 2018 Arun Isaac > ;;; Copyright =C2=A9 2018, 2019 Ricardo Wurmus > +;;; Copyright =C2=A9 2020 Brendan Tildesley > ;;; > ;;; 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 li= ke 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. > > - '(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 =3D, prefix, or suffix that select= s 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. > +including values from the users environment either after or before VALUE, > +whereas =3D overshadows any existing value, preventing the users environ= ment > +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 way= s on a > +different persons computer due to a difference in the inherited environm= ent > +variables. For example, this command: I'm not sure about including this "Otherwise ..." bit, I think what you say prior is sufficient. > > (wrap-program \"foo\" > '(\"PATH\" \":\" =3D (\"/gnu/.../bar/bin\")) Thanks again, Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----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----- --=-=-=--