diff mbox series

[bug#53257] gnu: foot: expose terminfo dirs via native-search-paths

Message ID 811cc55626870dbf37af3418e8effe191948541a.1642168254.git.florhizome@posteo.net
State New
Headers show
Series [bug#53257] gnu: foot: expose terminfo dirs via native-search-paths | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

florhizome Jan. 14, 2022, 2:02 p.m. UTC
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(+)

Comments

M Jan. 14, 2022, 7:02 p.m. UTC | #1
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.
florhizome Jan. 14, 2022, 10:52 p.m. UTC | #2
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:

> 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 Jan. 15, 2022, 11:45 a.m. UTC | #3
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
> 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.
M Jan. 15, 2022, 11:48 a.m. UTC | #4
Florian schreef op vr 14-01-2022 om 22:52 [+0000]:
> 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.
M Jan. 15, 2022, 12:30 p.m. UTC | #5
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
M Jan. 15, 2022, 2:24 p.m. UTC | #6
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 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
florhizome Jan. 15, 2022, 3:19 p.m. UTC | #7
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:

> 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
M Jan. 15, 2022, 3:38 p.m. UTC | #8
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 Jan. 15, 2022, 3:46 p.m. UTC | #9
Florian schreef op za 15-01-2022 om 15:19 [+0000]:
> [...]
> 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
<https://issues.guix.gnu.org/22138#8>.

>  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.
M Jan. 15, 2022, 3:46 p.m. UTC | #10
Florian schreef op za 15-01-2022 om 15:19 [+0000]:
> [...]
> 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
<https://issues.guix.gnu.org/22138#8>.

>  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.
florhizome Jan. 15, 2022, 6:46 p.m. UTC | #11
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?

> 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:

> 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 Jan. 23, 2022, 9:26 p.m. UTC | #12
Florian schreef op za 15-01-2022 om 18:46 [+0000]:
> 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.

>  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

> In other words, what next?

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22138 would help, but
doesn't address the cross-profile issue.  If 22138 is considered
notabug, then

>  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:

>  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.
Ludovic Courtès Jan. 28, 2022, 10:34 p.m. UTC | #13
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> 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:

An option we’ve used before, in fact to work around
<https://issues.guix.gnu.org/22138>, is to define certain variables
globally; on Guix System, you’ll see this in /etc/profile:

--8<---------------cut here---------------start------------->8---
# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
# find dictionaries.
export DICPATH=\
"$HOME/.guix-profile/share/hunspell\
:/run/current-system/profile/share/hunspell"

# Allow GStreamer-based applications to find plugins.
export GST_PLUGIN_PATH=\
"$HOME/.guix-profile/lib/gstreamer-1.0"
--8<---------------cut here---------------end--------------->8---

We should probably do the same for ‘TERMINFO_DIRS’.

WDYT?

(Of course that that doesn’t help on foreign distros, but maybe
‘TERMINFO_DIRS’ is already set there?)

Thanks,
Ludo’.
M Feb. 8, 2022, 12:46 p.m. UTC | #14
Ludovic Courtès schreef op vr 28-01-2022 om 23:34 [+0100]:
> Hi,
> 
> Maxime Devos <maximedevos@telenet.be> skribis:
> 
> > 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:
> 
> An option we’ve used before, in fact to work around
> <https://issues.guix.gnu.org/22138>, is to define certain variables
> globally; on Guix System, you’ll see this in /etc/profile:
> 
> --8<---------------cut here---------------start------------->8---
> # Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
> # find dictionaries.
> export DICPATH=\
> "$HOME/.guix-profile/share/hunspell\
> :/run/current-system/profile/share/hunspell"
> 
> # Allow GStreamer-based applications to find plugins.
> export GST_PLUGIN_PATH=\
> "$HOME/.guix-profile/lib/gstreamer-1.0"
> --8<---------------cut here---------------end--------------->8---
> 
> We should probably do the same for ‘TERMINFO_DIRS’.
>
> WDYT?

IIUC, that only works if 'foot' is installed in in the system profile,
and not if it is installed in the user profile.  Unlike, say,
'gnome-terminal', 'foot' doesn't seem like something that would be
in the system profile.  The variable would need to be added to
$GUIX_PROFILE/etc/profile instead.

... (me notices .guix-profile in the example above) ...

Ok, this could work with things in the user profile, but it's a rather
ad-hoc solution and won't work with "guix shell", so I would prefer
adding it to 'etc/profile'.

One option is to modify 'build-etc/profile' to always add
'TERMINFO_DIRS' (and maybe DICPATH, GUIX_LOCPATH and
SSL_CERT_DIR/FILE?) to the list of search paths.

> (Of course that that doesn’t help on foreign distros, but maybe
> ‘TERMINFO_DIRS’ is already set there?)

I'm currently on Debian+Guix.  $TERMINFO_DIRS is not set here.
Even if it was, I doubt you'd find the files for 'foot' in there
unless 'foot' is installed with the foreign distro's installer
-- AFAICT, 'foot' is not present in ncurses' terminfos.

If I do "grep -RF foot /usr/share/terminfo/", I don't find any results.
I do find results for 'kitty' though, which makes it odd that some
previous tests I did with 'kitty' failed ...

Greetings,
Maxime
Ludovic Courtès Feb. 10, 2022, 8:30 p.m. UTC | #15
Hi Maxime,

Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op vr 28-01-2022 om 23:34 [+0100]:

[...]

>> An option we’ve used before, in fact to work around
>> <https://issues.guix.gnu.org/22138>, is to define certain variables
>> globally; on Guix System, you’ll see this in /etc/profile:
>> 
>> --8<---------------cut here---------------start------------->8---
>> # Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
>> # find dictionaries.
>> export DICPATH=\
>> "$HOME/.guix-profile/share/hunspell\
>> :/run/current-system/profile/share/hunspell"
>> 
>> # Allow GStreamer-based applications to find plugins.
>> export GST_PLUGIN_PATH=\
>> "$HOME/.guix-profile/lib/gstreamer-1.0"
>> --8<---------------cut here---------------end--------------->8---
>> 
>> We should probably do the same for ‘TERMINFO_DIRS’.

[...]

> Ok, this could work with things in the user profile, but it's a rather
> ad-hoc solution and won't work with "guix shell", so I would prefer
> adding it to 'etc/profile'.

Yeah; like I wrote, it’s a workaround, but it solves the most common
issues.

> One option is to modify 'build-etc/profile' to always add
> 'TERMINFO_DIRS' (and maybe DICPATH, GUIX_LOCPATH and
> SSL_CERT_DIR/FILE?) to the list of search paths.

That’s not appealing to me; the way I see it, that’s going a bit too far
in the direction of dismissing per-package search paths in favor of
hard-coded lists of search paths.

>> (Of course that that doesn’t help on foreign distros, but maybe
>> ‘TERMINFO_DIRS’ is already set there?)
>
> I'm currently on Debian+Guix.  $TERMINFO_DIRS is not set here.
> Even if it was, I doubt you'd find the files for 'foot' in there
> unless 'foot' is installed with the foreign distro's installer
> -- AFAICT, 'foot' is not present in ncurses' terminfos.

Oh wait, I just realized that ‘foot’ comes with its own terminfo files.

In that case, the solution would be to wrap it so that it systematically
adds itself to TERMINFO_DIRS.  That’s the go-to solution in such
situations.

WDYT?

Ludo’.
M Feb. 10, 2022, 9:45 p.m. UTC | #16
Ludovic Courtès schreef op do 10-02-2022 om 21:30 [+0100]:
> Oh wait, I just realized that ‘foot’ comes with its own terminfo files.
> 
> In that case, the solution would be to wrap it so that it systematically
> adds itself to TERMINFO_DIRS.  That’s the go-to solution in such
> situations.
> 
> WDYT?

That would be (a suboption of) option (1) I suggested:

 1. patch the source code of 'foot' to set "TERMINFO_DIRS" or
   "TERMINFO" [...] (or use wrap-program in 'foot').

There is no disagreement from me here.

Greetings,
Maxime.
Ludovic Courtès Feb. 12, 2022, 9:49 p.m. UTC | #17
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op do 10-02-2022 om 21:30 [+0100]:
>> Oh wait, I just realized that ‘foot’ comes with its own terminfo files.
>> 
>> In that case, the solution would be to wrap it so that it systematically
>> adds itself to TERMINFO_DIRS.  That’s the go-to solution in such
>> situations.
>> 
>> WDYT?
>
> That would be (a suboption of) option (1) I suggested:
>
>  1. patch the source code of 'foot' to set "TERMINFO_DIRS" or
>    "TERMINFO" [...] (or use wrap-program in 'foot').

Perfect, sorry for overlooking it.

Florian, do you want to give it a try?  You need to look at
‘wrap-program’.

Ludo’.
diff mbox series

Patch

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