Subject: Re: [bug#53257] [PATCH] gnu: foot: Wrap the program to expose TERMINFO_DIRS

From: Maxime Devos <[email-masked]>
Date: Sun, 27 Feb 2022 20:22:28 +0100

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.