[PATCH] gnu: foot: expose terminfo dirs via native-search-paths

OpenSubmitted by florhizome.
Details
2 participants
  • florhizome
  • Maxime Devos
Owner
unassigned
Severity
normal
F
F
florhizome wrote on 14 Jan 15:02 +0100
(address . guix-patches@gnu.org)
811cc55626870dbf37af3418e8effe191948541a.1642168254.git.florhizome@posteo.net
Hi all,
I noticed foot did not behave normally whenever content would overflow it's current dimensions. when I installed alacritty in the same profile, this was fixed. Turned out, alacritty's declaration has a native-search-path field entry that fixed foot! Why not just search-paths, I can't tell. This might apply to further terminal emulators (kitty had problems starting emacs in some contexts for me but I would need to test that more), but for now, just foot!

* gnu/packages/terminals.scm (foot) [native-search-paths]: Add
search-path-specification for terminfo dirs
---
gnu/packages/terminals.scm | 4 ++++
1 file changed, 4 insertions(+)

Toggle diff (17 lines)
diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index a4fe97776d..1eb54dac80 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -849,6 +849,10 @@ (define-public foot
            pkg-config scdoc wayland-protocols))
     (inputs
      (list fcft libxkbcommon wayland))
+    (native-search-paths 
+     (list (search-path-specification
+            (variable "TERMINFO_DIRS")
+            (files '("share/terminfo")))))
     (synopsis "Wayland-native terminal emulator")
     (description
      "@command{foot} is a terminal emulator for systems using the Wayland
-- 
2.34.0
M
M
Maxime Devos wrote on 14 Jan 20:02 +0100
070637a9bb8fc9a51bd39b0a2666ede537bdc949.camel@telenet.be
florhizome schreef op vr 14-01-2022 om 14:02 [+0000]:
Toggle quote (8 lines)
> Hi all,
> I noticed foot did not behave normally whenever content would overflow it's current dimensions.
> when I installed alacritty in the same profile, this was fixed. Turned out, alacritty's
> declaration has a native-search-path field entry that fixed foot! Why not just search-paths,
> I can't tell. This might apply to further terminal emulators (kitty had problems starting emacs
> in some contexts for me but I would need to test that more), but for now, just foot!
>

Canonically, search path are set in ‘consumers’, not ‘producers’
(though setting it in ‘producers’ sometimes works). Here,
‘consumer’ = ncurses, maybe screen (why doesn't screen have a native-
search-paths? An oversight?), and ‘producer’ = some terminal emulator.

What application were you running in foot that leaded to an overrun?
Maybe we should add TERMINFO_DIRS to the native-search-paths of the
application. Basically all applications using ncurses need it, I
think?

The following seems relevant:
though personally that doesn't seem a bug to me.

Were you running emacs in the terminal? If so, maybe TERMINFO_DIRS
need to be added to 'emacs'?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeHI3BccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ju5AP4qneUKB6FE3vhkawqDnGE0Vpqk
yWrgG8lX5bWeDTTihQD/YGyNzgGLdRald1PtkzkTmCeH/OR3tjC/IvII1U0EXAQ=
=vud5
-----END PGP SIGNATURE-----


F
F
Florian wrote on 14 Jan 23:52 +0100
(address . 53257@debbugs.gnu.org)
87sftqlykz.fsf@tp-x230-guix.mail-host-address-is-not-set
Hi Maxime,
I understand this kinda differently so far:
We want to expose the path where foot installs it's terminfo via
TERMINFO_DIRS, so that
every program running in that Terminal can look it up. foot without the
patch emits the following env vars inside it's process:

~ $ env | grep TERM
COLORTERM=truecolor
TERM=foot-direct

(i configured it to use foot-direct, and not foot-xterm, which is the
other terminfo it installs, bc that should give me more colors in emacs)
now what happens is that neither foot nor programs running from it seem
to know what foot-direct is.
As I tried to describe, foot renders problematic stuff, whenever the
text it displays reaches it's borders, simply a long line does it, but
also looking up manpages (i would get a

WARNING: terminal is not fully functional
Press RETRUN to continue

when typing "git send-email --help" f.e.

Comparing to kitty: Running in kitty:

COLORTERM=truecolor
TERMINFO=/gnu/store/zhmzdniycjykb6igrx4avs9vsn4ngk5q-kitty-0.20.3/lib/kitty/terminfo
TERM=xterm-kitty

So, kitty exposes the exact path to it's terminfo files within it's
process. so, we are fine, most of the time. But when i try to edit a
file with elevated right's, emacs complains:

~ $ sudo emacs -nw .config/guix/home.scm
Passwort:
emacs: Terminal type xterm-kitty is not defined.
If that is not the actual type of terminal you have,
use the Bourne shell command 'TERM=...; export TERM' (C-shell:
'setenv TERM ...') to specify the correct type. It may be necessary
to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.

an interesting example with guix shell and nano:

~ $ guix shell nano -- nano ./.config/guix/home.scm
Folgende Ableitung wird erstellt:
/gnu/store/azcaj49div66k43afiiiq6njsjk8s5iv-profile.drv

Zertifikatsbündel der Zertifikatsautoritäten wird erstellt …
Liste der Emacs-Unterverzeichnisse wird erzeugt …
Schriftartenverzeichnis wird erstellt …
Verzeichnis von Info-Handbüchern wird erstellt …
Profil mit 1 Paket wird erstellt …
~ $ guix shell nano --pure -- nano ./.config/guix/home.scm
Error opening terminal: xterm-kitty.

(so, the first one worked, the second not.)
kitty works as long as i "preserve context" i would say, without
understanding in depth what happens.

So, to me it seems setting search-paths should make sense whenever you
want to expose a path in the store directory of a certain package, but
you cannot be sure to which package (otherwise, a wrapper would make
sense, and that's where your definiton of producer and consumer applies
better i think as it would be a much directer and clearer definition. ). In gnu guix we would want to take advantage of that rather more
then less i think, but it's poorly documented.
By my understanding, if emacs installs a terminfo file, yes, we could
set it's search-path field similar to alacritty. But it most definitely
makes sense for any terminal emulator that defines an own TERMINFO
variable and ships a terminfo file with that (and so a TERMINFO_DIR that
we want to expose to the environment).

Now what i don't understand is when I would set search-paths, but not
native-search-paths --- as i said, in this example search-paths would
make more sense to me, if I understood the two fields right.

Greetings,
Florian.

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (28 lines)
> florhizome schreef op vr 14-01-2022 om 14:02 [+0000]:
>> Hi all,
>> I noticed foot did not behave normally whenever content would overflow it's current dimensions.
>> when I installed alacritty in the same profile, this was fixed. Turned out, alacritty's
>> declaration has a native-search-path field entry that fixed foot! Why not just search-paths,
>> I can't tell. This might apply to further terminal emulators (kitty had problems starting emacs
>> in some contexts for me but I would need to test that more), but for now, just foot!
>>
>
> Canonically, search path are set in ‘consumers’, not ‘producers’
> (though setting it in ‘producers’ sometimes works). Here,
> ‘consumer’ = ncurses, maybe screen (why doesn't screen have a native-
> search-paths? An oversight?), and ‘producer’ = some terminal emulator.
>
> What application were you running in foot that leaded to an overrun?
> Maybe we should add TERMINFO_DIRS to the native-search-paths of the
> application. Basically all applications using ncurses need it, I
> think?
>
> The following seems relevant:
> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22138>
> though personally that doesn't seem a bug to me.
>
> Were you running emacs in the terminal? If so, maybe TERMINFO_DIRS
> need to be added to 'emacs'?
>
> Greetings,
> Maxime.
M
M
Maxime Devos wrote on 15 Jan 12:45 +0100
c183052fdcd8e67742566a53734de9886a67efc8.camel@telenet.be
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
Toggle quote (4 lines)
> Now what i don't understand is when I would set search-paths, but not
> native-search-paths --- as i said, in this example search-paths would
> make more sense to me, if I understood the two fields right.

I don't see what this has to do with your example, since you aren't
cross-compiling. There's only a difference between 'search-paths' and
'native-search-paths' when cross-compiling:

When a cross-compiler 'cross-gcc' and a native compiler 'gcc' are in
the native-inputs of some package, a C library 'x' is in the
native-inputs and a C library 'y' is in the (non-native) inputs, then:

* The native-search-path LIBRARY_PATH of 'gcc' is set to:

/gnu/store/[...]-x/include

(the cross-compiled 'y' library is ignored!)

* The (non-native) search-path CROSS_LIBRARY_PATH of 'cross-gcc' is
set to:

/gnu/store/[...]-y/include


(the native (not cross-compiled) 'x' library is ignored!)

Packages that don't cross-compile anything usually only have
native-search-paths and AFAIK this works.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeKzyxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lW8AP9nAcdhqOrgYWstgHzfBxYWY7yb
3pAEUtCO9NQpSWnqNQD/TJ3AFU/mc4yj4MDv4LhI5q+lzjDglVIk5GPdy9OKmAw=
=mv49
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 12:48 +0100
561e6b02ad2e38d27252c5265ce5063c7866dfdf.camel@telenet.be
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
Toggle quote (3 lines)
> By my understanding, if emacs installs a terminfo file, yes, we could
> set it's search-path field similar to alacritty.

What I suggested, is that emacs would have a search-path because it can
be used _inside_ a terminal as a terminal application,and hence might
be a ‘consumer’ of TERMINFO_DIR.

That said, from your examples it seems a good idea to (also?) include
TERMINFO_DIR in the producer -- I'll send a separate mail for that.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeK0hxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7muMAP0Vi5Vv0JX/GUnQcwnpMXmvb7cz
D8GitQ1bMp8K+a/kQgD7Bg+8QteH+TwHABpgJyFyKa7A+V1LfyxPk+2eAA8mQA0=
=hvxx
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 13:30 +0100
148b10e3686b511178ce6fc019d3c0e42868cc45.camel@telenet.be
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
Toggle quote (2 lines)
> [...]

I think the basic idea here is that the following should work:

$ guix shell --pure some-terminal-emulator -- some-terminal-emulator
# e.g., kitty
# from inside the terminal: (e.g. nano)
$ ~/.config/guix/current/bin/guix shell some-terminal-app -- some-terminal-app
# Variation: run under sudo

This works for kitty+nano, as you note, because kitty sets TERMINFO.
It also works for kitty+'emacs -nw'. However, in some combinations things won't work:

An example you noted is kitty+sudo+'emacs -nw'. This doesn't work for me either.
This seems to be caused by 'sudo' clearing too much. As I understand it, this is
only an illustrative counter-example, and not something that setting
'native-search-paths' could fix?

This patch is about 'foot', so I tried running foot+nano, but that failed because
I don't use wayland. Anyway, there seem to be a few options here:

1. patch the source code of 'foot' to set "TERMINFO_DIRS" or "TERMINFO"
appropriately (I'm not sure about the exact difference) (or use wrap-program
in 'foot').

The benefit of this above adding search paths, is that running 'foot'
directly from the store could work (somewhat niche though).

It would need to be investigated whether this works for your use case of
setting 'foot-direct' instead of 'foot-xterm'.

2. modify 'nano', 'emacs', ... to add a "TERMINFO_DIRS" search path.

A benefit of this approach above adding it to terminal emulators,
is that this how search paths are supposed to be used AFAIK
(adding an INFOPATH, LIBRARY_PATH, CROSS_LIBRARY_PATH, CPATH, ...
search path to every C library that has 'info' documentation is
rather cumbersome, instead INFOPATH ‘belongs’ to info readers,
LIBRARY_PATH etc. to compilers, ...).

A downside is that setting it here can be ‘too late’.
E.g., in the "guix shell terminal" then "guix shell editor"
example, the editor and terminal application are in separate profiles
so guix doesn't set TERMINFO_DIRS

3. Like (2), but add it to the terminal apps instead.

My order of preference: (1) > (3) > (2).
Here, (3) would be a lot easier than (1) but almost as good,
so maybe we could do (3) first and leave (1) for later?

AFAICT It's not only 'foot' that is affected, should we do (3) for all terminal
emulators that don't do (1) like kitty?

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeK+ZRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7hA1AP9Fyx3ZIEl+LAkrZfXOuKIrEKcF
q6MG1j2MND4DbAgIgwD9FIxhmK9jNNmJUXXTilhAsd/akYd7CmlNioRHf0Xq1gs=
=1YfM
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 15:24 +0100
9b79749f1902ca64bc0a544a697b4109920592f5.camel@telenet.be
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
Toggle quote (2 lines)
> [...]

I think the basic idea here is that the following should work:

$ guix shell --pure some-terminal-emulator -- some-terminal-emulator
# e.g., kitty
# from inside the terminal: (e.g. nano)
$ ~/.config/guix/current/bin/guix shell some-terminal-app -- some-terminal-app
# Variation: run under sudo

This works for kitty+nano, as you note, because kitty sets TERMINFO.
It also works for kitty+'emacs -nw'. However, in some combinations things won't work:

An example you noted is kitty+sudo+'emacs -nw'. This doesn't work for me either.
This seems to be caused by 'sudo' clearing too much. As I understand it, this is
only an illustrative counter-example, and not something that setting
'native-search-paths' could fix?

This patch is about 'foot', so I tried running foot+nano, but that failed because
I don't use wayland. Anyway, there are a few options here:

1. patch the source code of 'foot' to set "TERMINFO_DIRS" or "TERMINFO"
appropriately (I'm not sure about the exact difference) (or use wrap-program
in 'foot').

The benefit of this above adding search paths, is that running 'foot'
directly from the store could work (somewhat niche though).

It would need to be investigated whether this works for your use case of
setting 'foot-direct' instead of 'foot-xterm'.

2. modify 'nano', 'emacs', ... to add a "TERMINFO_DIRS" search path.

A benefit of this approach above adding it to terminal emulators,
is that this how search paths are supposed to be used AFAIK
(adding an INFOPATH, LIBRARY_PATH, CROSS_LIBRARY_PATH, CPATH, ...
search path to every C library that has 'info' documentation is
rather cumbersome, instead INFOPATH ‘belongs’ to info readers,
LIBRARY_PATH etc. to compilers, ...).

A downside is that setting it here can be ‘too late’.
E.g., in the "guix shell terminal" then "guix shell editor"
example, the editor and terminal application are in separate profiles
so guix doesn't set TERMINFO_DIRS

3. Like (2), but add it to the terminal apps instead.

My order of preference: (1) > (3) > (2).
Here, (3) would be a lot easier than (1) but almost as good,
so maybe we could do (3) first and leave (1) for later?

AFAICT It's not only 'foot' that is affected, should we do (3) for all terminal
emulators that don't do (1) like kitty?

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeLZGhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7rf7AP9rWn8cu9kuB/9HRSly/yuJBGvz
dvxHhoASBz+XC8dRHwD/a/a2M90tI688afFkL2cUxqBCPlPqUDhkqNmVJ/mJewM=
=gZZJ
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 16:38 +0100
1e090a31fe948da151e1d246a0c16002f4a44f34.camel@telenet.be
Florian schreef op za 15-01-2022 om 15:19 [+0000]:
Toggle quote (2 lines)
> Have you tried to add a search path to emacs or nano?

I don't, but I presume it would work -- at least 'ncurses' has a
TERMINFO_DIRS native-search-path, 'info-reader' and 'emacs' have an
INFOPATH ...
Toggle quote (5 lines)
> I kinda doubt this would do much; neither nano or emacs ship a terminfo
> for kitty, or for foot. What I think could work is wrapping nano and
> emacs and every terminal application that has problems to add a path
> derived from generically set env vars to point to the places where

It doesn't matter that nano and emacs don't ship terminfo files --
if a package in the profile (or build environment) has some search
path, then the search path is set with corresponding directories from
_every_ package (*), irrespective of whether they have that search
path.

So as long as 'nano/emacs/vi/...' and 'kitty/foot/gnome-terminal-
emulator/...' are in the _same_ profile, the environment variable
of the search path is set.

They aren't always in the same profile though,

(*) with some restrictions w.r.t. cross-compilation, native-search-
path/search-path, native-inputs/inputs ...

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeLqaRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7uMOAQD0WSZg4/8x9oFepLmdvfF1es//
2QEwShEUMl1sI0502QEAyhLvZaZdrY5MbFTM1J7LjZu1y+RxcQEukPYkDxksNwg=
=CaV1
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 16:46 +0100
9e0df655bf546badc95300032d4c4b815a68ba68.camel@telenet.be
Florian schreef op za 15-01-2022 om 15:19 [+0000]:
Toggle quote (6 lines)
> [...]
> As I see major problems f.e. with QT applications, that seem related to
> not setting search paths, a proposal of mine for the future would be to improve/
> actually introduce good documentation to the search-patch
> variables (and their relationship to profiles and propagated inputs)

About documentation, you might be interested in

Toggle quote (19 lines)
> but
> maybe simplify setting a search-path correspanding to a more distinct
> group of programs. I could imagine this as something like a search-path
> "type", working out like this:
> (package
> ...
> (native-search-paths
> (list
> (search-path-specification
> (type terminal-emulator))
> ...)
> )
> at first this would just be the same as the code added to foot, but it
> could be refined (people might be able to see overlaps, and integrate
> some filtering or other optimization for a specific group. Also you could maybe eventually say "install a
> package but without these search-paths"). For groups like qt plugins,
> it could maybe be included in the qt-wrap functionalities to look for
> the paths where plugins are installed and add the corresponding search paths automatically.

Not sure what you mean here, when building a package it is unknown
what plug-ins will be used in advance. The point of search paths is
having some kind of extensibility, setting the search path environment
variables in qt-wrap would undo that.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeLsWBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sPNAQCXecDLOAz3d4MV/7BC0/wv2gwM
KqR+IKjN3yGsX01+2AD/WKhKRhjQSr9lkG4KzjZU8MUMDtOnWtGyDn1D/sG9+AU=
=I8BS
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 15 Jan 16:46 +0100
f6e522e4a12cb3c512bd0ca8dafdc415cffc89fd.camel@telenet.be
Florian schreef op za 15-01-2022 om 15:19 [+0000]:
Toggle quote (6 lines)
> [...]
> As I see major problems f.e. with QT applications, that seem related to
> not setting search paths, a proposal of mine for the future would be to improve/
> actually introduce good documentation to the search-patch
> variables (and their relationship to profiles and propagated inputs)

About documentation, you might be interested in

Toggle quote (19 lines)
> but
> maybe simplify setting a search-path correspanding to a more distinct
> group of programs. I could imagine this as something like a search-path
> "type", working out like this:
> (package
> ...
> (native-search-paths
> (list
> (search-path-specification
> (type terminal-emulator))
> ...)
> )
> at first this would just be the same as the code added to foot, but it
> could be refined (people might be able to see overlaps, and integrate
> some filtering or other optimization for a specific group. Also you could maybe eventually say "install a
> package but without these search-paths"). For groups like qt plugins,
> it could maybe be included in the qt-wrap functionalities to look for
> the paths where plugins are installed and add the corresponding search paths automatically.

Not sure what you mean here, when building a package it is unknown
what plug-ins will be used in advance. The point of search paths is
having some kind of extensibility, setting the search path environment
variables in qt-wrap would undo that.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeLsZRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lC7AP0fJiWus99UjrcOwKKPEQg/Gf0L
mII2f//0HQFq446DSAEAkrLcb6olLy5OZzyikkkzmkkyzzNdUy2CjSPmc3GlbQc=
=HH7O
-----END PGP SIGNATURE-----


F
F
Florian wrote on 15 Jan 16:19 +0100
87o84dm3fs.fsf@tp-x230-guix.mail-host-address-is-not-set
Hey Maxime,

the comment about native-search-paths vs search-paths was just for
better understanding.I thought they work like native inputs vs inputs,
but it seems like it's quite the opposite.

If my understanding holds, setting TERMINFO_DIRS with
native-search-paths could help all terminals that have a non-generic
terminfo (not each would). But i couldn't tell you which ones those are.
As I see major problems f.e. with QT applications, that seem related to
not setting search paths, a proposal of mine for the future would be to improve/ actually introduce good documentation to the search-patch
variables (and their relationship to profiles and propagated inputs) but
maybe simplify setting a search-path correspanding to a more distinct
group of programs. I could imagine this as something like a search-path
"type", working out like this:
(package
...
(native-search-paths
(list
(search-path-specification
(type terminal-emulator))
...)
)

at first this would just be the same as the code added to foot, but it
could be refined (people might be able to see overlaps, and integrate
some filtering or other optimization for a specific group. Also you could maybe eventually say "install a
package but without these search-paths"). For groups like qt plugins,
it could maybe be included in the qt-wrap functionalities to look for
the paths where plugins are installed and add the corresponding search paths automatically.

Have you tried to add a search path to emacs or nano?
I kinda doubt this would do much; neither nano or emacs ship a terminfo
for kitty, or for foot. What I think could work is wrapping nano and
emacs and every terminal application that has problems to add a path
derived from generically set env vars to point to the places where
terminfo files might be installed a la
TERMINFO_DIRS=$TERMINFO_DIRS:$XDG_DATA_DIRS/
this could actually be helpful on foreign distros, but i don't know if
apps don't already trythis by themselves.

So, to get more specific on what to do: Of your suggestions I would say
why not do 3 for foot immediately like my patch suggests, it fixes the
most immediate problems in a comprehensible and by that easily revertible way. I don't
think 2 helps much, maybe still misunderstanding things.
For 1) I don't know if I could do this, and I'm not really
motivated. It also doesn't really clash with 3. There also might be
usecases like programs
that need info about installed terminfos without being run from the
respective terminal emulator, where having the env var in the shell
could come handy, esp for usecases like guix on a foreign distro. but
i'm not sure if these exist here.
I also remember reading, when researching the problem with kitty sudo
emacs, possibilites for preserving chosen environment variables when switching
between different contexts, which should help.

oh, and i just set foot-direct recently, when i was investigating
this. the problems have stuck with me.

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (57 lines)
> Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
>> [...]
>
> I think the basic idea here is that the following should work:
>
> $ guix shell --pure some-terminal-emulator -- some-terminal-emulator
> # e.g., kitty
> # from inside the terminal: (e.g. nano)
> $ ~/.config/guix/current/bin/guix shell some-terminal-app -- some-terminal-app
> # Variation: run under sudo
>
> This works for kitty+nano, as you note, because kitty sets TERMINFO.
> It also works for kitty+'emacs -nw'. However, in some combinations things won't work:
>
> An example you noted is kitty+sudo+'emacs -nw'. This doesn't work for me either.
> This seems to be caused by 'sudo' clearing too much. As I understand it, this is
> only an illustrative counter-example, and not something that setting
> 'native-search-paths' could fix?
>
> This patch is about 'foot', so I tried running foot+nano, but that failed because
> I don't use wayland. Anyway, there seem to be a few options here:
>
> 1. patch the source code of 'foot' to set "TERMINFO_DIRS" or "TERMINFO"
> appropriately (I'm not sure about the exact difference) (or use wrap-program
> in 'foot').
>
> The benefit of this above adding search paths, is that running 'foot'
> directly from the store could work (somewhat niche though).
>
> It would need to be investigated whether this works for your use case of
> setting 'foot-direct' instead of 'foot-xterm'.
>
> 2. modify 'nano', 'emacs', ... to add a "TERMINFO_DIRS" search path.
>
> A benefit of this approach above adding it to terminal emulators,
> is that this how search paths are supposed to be used AFAIK
> (adding an INFOPATH, LIBRARY_PATH, CROSS_LIBRARY_PATH, CPATH, ...
> search path to every C library that has 'info' documentation is
> rather cumbersome, instead INFOPATH ‘belongs’ to info readers,
> LIBRARY_PATH etc. to compilers, ...).
>
> A downside is that setting it here can be ‘too late’.
> E.g., in the "guix shell terminal" then "guix shell editor"
> example, the editor and terminal application are in separate profiles
> so guix doesn't set TERMINFO_DIRS
>
> 3. Like (2), but add it to the terminal apps instead.
>
> My order of preference: (1) > (3) > (2).
> Here, (3) would be a lot easier than (1) but almost as good,
> so maybe we could do (3) first and leave (1) for later?
>
> AFAICT It's not only 'foot' that is affected, should we do (3) for all terminal
> emulators that don't do (1) like kitty?
>
> Greetings,
> Maxime
F
F
Florian wrote on 15 Jan 19:46 +0100
87czksalbd.fsf@tp-x230-guix.mail-host-address-is-not-set
Hello Maxime,
to me, the functionality of search-paths seemed exactly communicating
paths *beyond* a single profile. It would make more sense to set
them with the package that installs the decisive files to me, at least
as a thumb-of-rule. Your examples don't really counter that, though, i
think ;)
In other words, what next?

Toggle quote (5 lines)
> So as long as 'nano/emacs/vi/...' and 'kitty/foot/gnome-terminal-
> emulator/...' are in the _same_ profile, the environment variable
> of the search path is set.


Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (29 lines)
> Florian schreef op za 15-01-2022 om 15:19 [+0000]:
>> Have you tried to add a search path to emacs or nano?
>
> I don't, but I presume it would work -- at least 'ncurses' has a
> TERMINFO_DIRS native-search-path, 'info-reader' and 'emacs' have an
> INFOPATH ...
>
>> I kinda doubt this would do much; neither nano or emacs ship a terminfo
>> for kitty, or for foot. What I think could work is wrapping nano and
>> emacs and every terminal application that has problems to add a path
>> derived from generically set env vars to point to the places where
>
> It doesn't matter that nano and emacs don't ship terminfo files --
> if a package in the profile (or build environment) has some search
> path, then the search path is set with corresponding directories from
> _every_ package (*), irrespective of whether they have that search
> path.
>
> So as long as 'nano/emacs/vi/...' and 'kitty/foot/gnome-terminal-
> emulator/...' are in the _same_ profile, the environment variable
> of the search path is set.
>
> They aren't always in the same profile though,
>
> (*) with some restrictions w.r.t. cross-compilation, native-search-
> path/search-path, native-inputs/inputs ...
>
> Greetings,
> Maxime.
M
M
Maxime Devos wrote 2 days ago
da191932588007c654be2ba6d58d8e949e0d9c9a.camel@telenet.be
Florian schreef op za 15-01-2022 om 18:46 [+0000]:
Toggle quote (3 lines)
> to me, the functionality of search-paths seemed exactly communicating
> paths *beyond* a single profile. 

Search paths can be used for that (though that's rather fragile), but I
don't quite see what this has to do with foot, which can be patched or
wrapped to set TERMINFO_DIR or TERMINFO_DIRS as appropriate.

Toggle quote (5 lines)
> It would make more sense to set
> them with the package that installs the decisive files to me, at least
> as a thumb-of-rule. Your examples don't really counter that, though, i
> think ;)

It would seem to me that adding:

* LIBRARY_PATH, CROSS_LIBRARY_PATH, C_INCLUDE_PATH, etc.
to every C library package
* INFOPATH to every package with an info manual
* MANPATH to every package with man pages
* EMACSLOADPATH to every emacs package
* GUILE_LOAD_PATH / GUILE_LOAD_COMPILED_PATH to every Guile library
or package with Guile bindings
* GUIX_PYTHONPATH to every Python package or package with Python
bindings
* PKG_CONFIG_PATH to every package with pkg-config files
* GI_TYPELIB_PATH for ... I'm not sure exactly
* similar things for R, Haskell, Minetest, OCaml, Tcl, Lua, Coq ...

would be rather tedious and it easy to forget.

How about keeping things simple and not creating much more work,
by instead adding these search paths to consumers

* GCC for LIBRARY_PATH etc.
* info-reader and emacs for INFOPATH
* man-db for MANPATH
* emacs for EMACSLOADPATH
* guile for GUILE_LOAD_PATH / GUILE_LOAD_COMPILED_PATH
* etc.

like we're doing currently? The number of packages in the list below
is much smaller than the number of packages in the list above

Toggle quote (2 lines)
> In other words, what next?

doesn't address the cross-profile issue.  If 22138 is considered
notabug, then

Toggle quote (16 lines)
> 2. modify 'nano', 'emacs', ... to add a "TERMINFO_DIRS" search path.
>
> A benefit of this approach above adding it to terminal emulators,
> is that this how search paths are supposed to be used AFAIK
> (adding an INFOPATH, LIBRARY_PATH, CROSS_LIBRARY_PATH, CPATH, ...
> search path to every C library that has 'info' documentation is
> rather cumbersome, instead INFOPATH ‘belongs’ to info readers,
> LIBRARY_PATH etc. to compilers, ...).
>
> A downside is that setting it here can be ‘too late’.
> E.g., in the "guix shell terminal" then "guix shell editor"
> example, the editor and terminal application are in separate
> profiles
> so guix doesn't set TERMINFO_DIRS
>

For addressing the cross-profile issue:

Toggle quote (15 lines)
> 1. patch the source code of 'foot' to set "TERMINFO_DIRS" or
> "TERMINFO"
> appropriately (I'm not sure about the exact difference) (or use
> wrap-program
> in 'foot').
>
> The benefit of this above adding search paths, is that running
> 'foot'
> directly from the store could work (somewhat niche though).
>
> It would need to be investigated whether this works for your use
> case of
> setting 'foot-direct' instead of 'foot-xterm'.
>

There was some terminal emulator setting TERMINFO_DIR (!=
TERMINFO_DIRS) I think, maybe that would be worth investigating as
well.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYe3IIhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7iGlAP43px2VRT6E1iNfpyfys+MHA39g
JQEHK7QrnkVcxAp5QQEAqZXEj+9W+lhROnqDxbfAXLEO5TKQ8SkVgtGSlDMAdAA=
=tgop
-----END PGP SIGNATURE-----


?
Your comment

Commenting via the web interface is currently disabled.

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