Message ID | 20220227183415.12487-1-kevinboulain@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CC46A27BBEA; Sun, 27 Feb 2022 18:33:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5C09827BBE9 for <patchwork@mira.cbaines.net>; Sun, 27 Feb 2022 18:33:19 +0000 (GMT) Received: from localhost ([::1]:42886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) id 1nOOMA-0007ro-Ej for patchwork@mira.cbaines.net; Sun, 27 Feb 2022 13:33:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nOOLu-0007rQ-CA for guix-patches@gnu.org; Sun, 27 Feb 2022 13:33:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:37063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nOOLu-0005k3-3t for guix-patches@gnu.org; Sun, 27 Feb 2022 13:33:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nOOLt-0003uV-Tt for guix-patches@gnu.org; Sun, 27 Feb 2022 13:33:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53257] [PATCH] gnu: foot: Wrap the program to expose TERMINFO_DIRS References: <811cc55626870dbf37af3418e8effe191948541a.1642168254.git.florhizome@posteo.net> In-Reply-To: <811cc55626870dbf37af3418e8effe191948541a.1642168254.git.florhizome@posteo.net> Resent-From: Kevin Boulain <kevinboulain@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 27 Feb 2022 18:33:01 +0000 Resent-Message-ID: <handler.53257.B53257.164598677015013@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53257 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53257@debbugs.gnu.org Cc: Kevin Boulain <kevinboulain@gmail.com> Received: via spool by 53257-submit@debbugs.gnu.org id=B53257.164598677015013 (code B ref 53257); Sun, 27 Feb 2022 18:33:01 +0000 Received: (at 53257) by debbugs.gnu.org; 27 Feb 2022 18:32:50 +0000 Received: from localhost ([127.0.0.1]:59193 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1nOOLi-0003u5-CK for submit@debbugs.gnu.org; Sun, 27 Feb 2022 13:32:50 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:44630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <kevinboulain@gmail.com>) id 1nOOLg-0003tr-IR for 53257@debbugs.gnu.org; Sun, 27 Feb 2022 13:32:49 -0500 Received: by mail-ed1-f45.google.com with SMTP id x5so14516404edd.11 for <53257@debbugs.gnu.org>; Sun, 27 Feb 2022 10:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/T8Jx+6TE87ZLCN509xCG4OplMh/cJoDPPoM4RBOrkI=; b=LYdkrCJOlMwvDMEgg9AGpxcP1IPwcFumdsKay/NK+UrJxQ/+NE6jGZd4+f+NoNxzEU 7/SYT3KirshtWhpoOOXfnd7mfrSLHEIpNNYR5KjMxiAaWG0wKe1REW70KigiZ0/Fbh3d aEJQIFMemGA2vuIC64tgWcp1Juqp9Zxbp/tMoJV3rkj1PB3Ddow1ZPNhvoe0QrbzA1A/ p5fahH/XeewjbUzGK7DYDvemLWlttoMSAALExihPXe0kHZF/0PWaWrF57Usod0mAzkcR p6v7olpOT3X+RnREaPiSmn68J9zsDIjFXrU38KJxDkl7zvwpkOmt3sYUHXG1Mzcf2OW5 nm7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/T8Jx+6TE87ZLCN509xCG4OplMh/cJoDPPoM4RBOrkI=; b=wxiZq52AcrQT2k2WjR16PKOiX3dnZRgQ7arsJmWQmCobtFqdjskWpSNH5DHRxCpUtP o9lmFFq0+fbotdZHhKb08GYvgS6sdbPlzw4goktSbGyDLRrTL2LwebvbNU7wgCEoj782 n/PTVvt6/YHa7AIkNQG+5JCBGke5jLeq/C7BVlmlQc99i+Pt1Hm5sQQDhsbJWAuN7rUq rB8VzsyLNcG/xC1WV4+oIhwrSwYDZ4cfpW5jkq5NxE0NUHf8UkAkxU7Qs7Um/Z1nj2KJ ba/iaKU/4kCnMXYUS1nIdXk83Q2WG2UxrwHPvcIVB9XsjHRq8lm94xjIGVHu+aIsxUwP o6Xw== X-Gm-Message-State: AOAM530fS/TPnAo0aRfqi355AYGZ3FBX7N+fZpgDAXDSqj13ibotsH0s uzie/DaFVO1JAeE73uyrKD+2cFf3WBM= X-Google-Smtp-Source: ABdhPJyMKrcW6UuFppj4KN7QgOQZ2IhCE3WTkojD4D23SWOXQxbN0GTYDX5hvQJH0TGu82ZSsvJvvg== X-Received: by 2002:a05:6402:90b:b0:412:a7cc:f5f9 with SMTP id g11-20020a056402090b00b00412a7ccf5f9mr15947655edz.136.1645986762255; Sun, 27 Feb 2022 10:32:42 -0800 (PST) Received: from localhost.localdomain ([51.154.70.17]) by smtp.gmail.com with ESMTPSA id q10-20020aa7cc0a000000b0040f826f09fdsm5035175edt.81.2022.02.27.10.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 10:32:41 -0800 (PST) From: Kevin Boulain <kevinboulain@gmail.com> Date: Sun, 27 Feb 2022 19:34:15 +0100 Message-Id: <20220227183415.12487-1-kevinboulain@gmail.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#53257] gnu: foot: Wrap the program to expose TERMINFO_DIRS
|
|
Commit Message
Kevin Boulain
Feb. 27, 2022, 6:34 p.m. UTC
As discussed in https://issues.guix.gnu.org/53257, it appears the preferred way to expose TERMINFO_DIRS to programs running under a terminal is to wrap the terminal with a script that sets TERMINFO_DIRS before exec'ing it. This is less invasive than unconditionally setting TERMINFO_DIRS in the profile (via native-search-paths) as this particular environment variable is only necessary when running the terminal itself. * gnu/packages/terminals.scm (foot): Export TERMINFO_DIRS. Tested: ./pre-inst-env guix install foot cat "$(which foot)" #!/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash export TERMINFO_DIRS="/gnu/store/6dwhps0cgzk0z7c3q2q596l52ibzdl5c-foot-1.11.0/share/terminfo${TERMINFO_DIRS:+:}$TERMINFO_DIRS" exec -a "$0" "/gnu/store/6dwhps0cgzk0z7c3q2q596l52ibzdl5c-foot-1.11.0/bin/.foot-real" "$@" --- gnu/packages/terminals.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Comments
I hope you don't mind, I went ahead and used wrap-program as discussed (I was encountering this issue and had a very similar patch as the OP's). Did I get the idea that was discussed in this thread right? If yes, should I send another patch to fix the other terminals (e.g.: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/terminals.scm?id=85a5110de79f4fe9fd822ede3915654ee699d6c5#n220)? On Sun, 27 Feb 2022 at 19:32, Kevin Boulain <kevinboulain@gmail.com> wrote: > > As discussed in https://issues.guix.gnu.org/53257, it appears the > preferred way to expose TERMINFO_DIRS to programs running under a > terminal is to wrap the terminal with a script that sets TERMINFO_DIRS > before exec'ing it. > This is less invasive than unconditionally setting TERMINFO_DIRS in the > profile (via native-search-paths) as this particular environment > variable is only necessary when running the terminal itself. > > * gnu/packages/terminals.scm (foot): Export TERMINFO_DIRS. > > Tested: > ./pre-inst-env guix install foot > cat "$(which foot)" > #!/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash > export TERMINFO_DIRS="/gnu/store/6dwhps0cgzk0z7c3q2q596l52ibzdl5c-foot-1.11.0/share/terminfo${TERMINFO_DIRS:+:}$TERMINFO_DIRS" > exec -a "$0" "/gnu/store/6dwhps0cgzk0z7c3q2q596l52ibzdl5c-foot-1.11.0/bin/.foot-real" "$@" > --- > gnu/packages/terminals.scm | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm > index 06fa341472..65553ac295 100644 > --- a/gnu/packages/terminals.scm > +++ b/gnu/packages/terminals.scm > @@ -852,7 +852,19 @@ (define-public foot > ;; also to address a GCC 10 issue when doing PGO builds. > #:build-type "release" > ;; Enable LTO as recommended by INSTALL.md. > - #:configure-flags '("-Db_lto=true"))) > + #:configure-flags '("-Db_lto=true") > + ;; Ensure the terminfo database is available to programs spawned under > + ;; the terminal. > + #:phases > + (modify-phases %standard-phases > + (add-after 'install 'wrap-program > + (lambda* (#:key inputs outputs #:allow-other-keys) > + (let* ((out (assoc-ref outputs "out"))) > + ;; footclient executes programs under the server process, > + ;; there is no need to wrap it too. > + (wrap-program (string-append out "/bin/foot") > + `("TERMINFO_DIRS" ":" prefix > + (,(string-append out "/share/terminfo")))))))))) > (native-inputs > (list ncurses ;for 'tic' > pkg-config scdoc wayland-protocols)) > -- > 2.34.0 >
Kevin Boulain schreef op zo 27-02-2022 om 19:34 [+0100]: > + (modify-phases %standard-phases > + (add-after 'install 'wrap-program > + (lambda* (#:key inputs outputs #:allow-other-keys) > + (let* ((out (assoc-ref outputs "out"))) > + ;; footclient executes programs under the server process, > + ;; there is no need to wrap it too. > + (wrap-program (string-append out "/bin/foot") > + `("TERMINFO_DIRS" ":" prefix > + (,(string-append out "/share/terminfo")))))))))) You'll need to add 'bash-minimal' to 'inputs', such that this works even when cross-compiling. I think "./pre-inst-env guix lint foot" would warn about this. Also, this can be simplified a bit, to ,#(modify-phases %standard-phases (add-after 'install 'wrap-program (lambda _ (let ((out #$output)) ;; footclient executes programs under the server process, ;; there is no need to wrap it too. (wrap-program (string-append out "/bin/foot") `("TERMINFO_DIRS" ":" prefix (,(string-append out "/share/terminfo")))))))))) or, reducing the whitespace: ,#(modify-phases %standard-phases (add-after 'install 'wrap-program (lambda _ (define out #$output) ;; footclient executes programs under the server process, ;; there is no need to wrap it too. (wrap-program (string-append out "/bin/foot") `("TERMINFO_DIRS" ":" prefix (,(string-append out "/share/terminfo"))))))))) (you'll need to add (guix gexp) to the list of imports to do this) YMMV on whether this is an improvement. I hope you don't mind, I went ahead and used wrap-program as discussed (I was encountering this issue and had a very similar patch as the OP's). Did I get the idea that was discussed in this thread right? Yes, this was the idea, though to be 100% sure it would need to be tested (by running "guix shell --pure foot -- foot" and then running ~/.guix-profile/bin/SOME-NCURSES-APP in the terminal, or something like that. If yes, should I send another patch to fix the other terminals (e.g.: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/terminals.scm?id=85a5110de79f4fe9fd822ede3915654ee699d6c5#n220 )? That would be nice, but keep in mind that this might not be needed for every terminal app -- some apps set TERMINFODIR automatically (I forgot which) and hence don't need any wrapping. Greetings, Maxime.
Thank you, I'll send a follow-up patch to resolve the concerns (that's greatly appreciated, I'm new at both Guix and Scheme). I did test it with an ncurses program so I can confirm it works (no complaints about an unknown terminal anymore). I only have a single concern about this approach: native-search-paths made the terminfo database somewhat 'global' (as long the shell sourced the Guix profile) and it made stuff like SSH less awkward: by installing foot on both the client and the server, ncurses applications could 'just work'. Now, by making the terminfo database only visible inside the terminal itself, SSH is pretty much never guaranteed to work seamlessly (however, foot appears to be compatible with xterm so it's not that much of an issue: https://codeberg.org/dnkl/foot/src/branch/master/INSTALL.md#terminfo). I agree this has always been a pain point with ncurses programs and the proper solution would be to upstream the terminal's description to terminfo so it's easily available everywhere (or people can always install it manually), but I prefer following the recommendations of the maintainers here :) On Sun, 27 Feb 2022 at 20:22, Maxime Devos <maximedevos@telenet.be> wrote: > > Kevin Boulain schreef op zo 27-02-2022 om 19:34 [+0100]: > > + (modify-phases %standard-phases > > + (add-after 'install 'wrap-program > > + (lambda* (#:key inputs outputs #:allow-other-keys) > > + (let* ((out (assoc-ref outputs "out"))) > > + ;; footclient executes programs under the server process, > > + ;; there is no need to wrap it too. > > + (wrap-program (string-append out "/bin/foot") > > + `("TERMINFO_DIRS" ":" prefix > > + (,(string-append out "/share/terminfo")))))))))) > > > You'll need to add 'bash-minimal' to 'inputs', such that this works > even when cross-compiling. I think "./pre-inst-env guix lint foot" > would warn about this. > > Also, this can be simplified a bit, to > > ,#(modify-phases %standard-phases > (add-after 'install 'wrap-program > (lambda _ > (let ((out #$output)) > ;; footclient executes programs under the server process, > ;; there is no need to wrap it too. > (wrap-program (string-append out "/bin/foot") > `("TERMINFO_DIRS" ":" prefix > (,(string-append out "/share/terminfo")))))))))) > > or, reducing the whitespace: > > > ,#(modify-phases %standard-phases > (add-after 'install 'wrap-program > (lambda _ > (define out #$output) > ;; footclient executes programs under the server process, > ;; there is no need to wrap it too. > (wrap-program (string-append out "/bin/foot") > `("TERMINFO_DIRS" ":" prefix > (,(string-append out "/share/terminfo"))))))))) > > (you'll need to add (guix gexp) to the list of imports to do this) > > YMMV on whether this is an improvement. > > I hope you don't mind, I went ahead and used wrap-program as > discussed (I was encountering this issue and had a very similar patch > as the OP's). Did I get the idea that was discussed in this thread > right? > > Yes, this was the idea, though to be 100% sure it would need to be tested (by running "guix shell --pure foot -- foot" and then running > ~/.guix-profile/bin/SOME-NCURSES-APP in the terminal, or something like that. > > If yes, should I send another patch to fix the other terminals > (e.g.: > > https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/terminals.scm?id=85a5110de79f4fe9fd822ede3915654ee699d6c5#n220 > )? > > That would be nice, but keep in mind that this might not be needed > for every terminal app -- some apps set TERMINFODIR automatically (I forgot which) and hence don't need any wrapping. > > Greetings, > Maxime.
> You'll need to add 'bash-minimal' to 'inputs', such that this works > even when cross-compiling. I think "./pre-inst-env guix lint foot" > would warn about this. It does warn about it, I only ran './pre-inst-env guix style foot' (but I limited the reformatting to my changes), my bad. > Also, this can be simplified a bit, to [...] Yup, thanks! > Yes, this was the idea, though to be 100% sure it would need to be tested (by running "guix shell --pure foot -- foot" and then running > ~/.guix-profile/bin/SOME-NCURSES-APP in the terminal, or something like that. I confirm it works (for example tput doesn't complain anymore and I can start emacs -nw).
diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm index 06fa341472..65553ac295 100644 --- a/gnu/packages/terminals.scm +++ b/gnu/packages/terminals.scm @@ -852,7 +852,19 @@ (define-public foot ;; also to address a GCC 10 issue when doing PGO builds. #:build-type "release" ;; Enable LTO as recommended by INSTALL.md. - #:configure-flags '("-Db_lto=true"))) + #:configure-flags '("-Db_lto=true") + ;; Ensure the terminfo database is available to programs spawned under + ;; the terminal. + #:phases + (modify-phases %standard-phases + (add-after 'install 'wrap-program + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out"))) + ;; footclient executes programs under the server process, + ;; there is no need to wrap it too. + (wrap-program (string-append out "/bin/foot") + `("TERMINFO_DIRS" ":" prefix + (,(string-append out "/share/terminfo")))))))))) (native-inputs (list ncurses ;for 'tic' pkg-config scdoc wayland-protocols))