Patchwork [1/4] gnu: Add XFILESEARCH path to profiles' environment.

login
register
mail settings
Submitter John Darrington
Date Nov. 25, 2016, 7:08 p.m.
Message ID <1480100924-23868-1-git-send-email-jmd@gnu.org>
Download mbox | patch
Permalink /patch/17897/
State New
Headers show

Comments

John Darrington - Nov. 25, 2016, 7:08 p.m.
* gnu/system.scm (operating-system-etc-service): Add new environment variable:
XFILESEARCHPATH
---
 doc/guix.texi  | 30 ++++++++++++++++++++++++++++++
 gnu/system.scm | 25 +++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
Ludovic Courtès - Nov. 27, 2016, 9:22 p.m.
Hello!

John Darrington <jmd@gnu.org> skribis:

> * gnu/system.scm (operating-system-etc-service): Add new environment variable:
> XFILESEARCHPATH
> ---
>  doc/guix.texi  | 30 ++++++++++++++++++++++++++++++
>  gnu/system.scm | 25 +++++++++++++++++++++++++
>  2 files changed, 55 insertions(+)

The guix.texi change is missing from the log.

> diff --git a/doc/guix.texi b/doc/guix.texi
> index e64c361..9d133bb 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -1209,6 +1209,36 @@ data in the right format.
>  This is important because the locale data format used by different libc
>  versions may be incompatible.
>  
> +@subsection X Window System
> +@vindex XFILESEARCHPATH
> +@vindex @code{Xt}
> +@vindex X Toolkit Intrinsics
> +@vindex @command{xterm}
> +
> +If you intend to use X Toolkit Intrinsics client applications such
> +as @command{xterm} then you should define the @code{XFILESEARCHPATH}
> +environment variable:
> +
> +@example
> +$ export XFILESEARCHPATH="$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:
> +  $HOME/.guix-profile/share/X11/%l/%T/%N%C%S:
> +  $HOME/.guix-profile/share/X11/%T/%N%C%S:
> +  $HOME/.guix-profile/share/X11/%L/%T/%N%S:
> +  $HOME/.guix-profile/share/X11/%l/%T/%N%S:
> +  $HOME/.guix-profile/share/X11/%T/%N%S:
> +  $HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:
> +  $HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:
> +  $HOME/.guix-profile/lib/X11/%T/%N%C%S:
> +  $HOME/.guix-profile/lib/X11/%L/%T/%N%S:
> +  $HOME/.guix-profile/lib/X11/%l/%T/%N%S:
> +  $HOME/.guix-profile/lib/X11/%T/%N%S"
> +@end example

Seriously?!  I mean, we can reasonably ask people to do that, can we?
Is there another way?

Naive approach to look for candidate variables:

--8<---------------cut here---------------start------------->8---
$ ltrace -e getenv xterm 2>&1 |grep '"X'|sort -u
libX11.so.6->getenv("XCOMPOSECACHE")             = nil
libX11.so.6->getenv("XCOMPOSEFILE")              = nil
libX11.so.6->getenv("XKB_DEBUG")                 = nil
libX11.so.6->getenv("XKB_DISABLE")               = nil
libX11.so.6->getenv("XKEYSYMDB")                 = nil
libX11.so.6->getenv("XLIBBUFFERSIZE")            = nil
libX11.so.6->getenv("XLIB_SKIP_ARGB_VISUALS")    = nil
libX11.so.6->getenv("XLOCALEDIR")                = nil
libX11.so.6->getenv("XMODIFIERS")                = nil
libXau.so.6->getenv("XAUTHORITY")                = "/home/ludo/.Xauthority"
libXt.so.6->getenv("XAPPLRESDIR")                = nil
libXt.so.6->getenv("XENVIRONMENT")               = nil
libXt.so.6->getenv("XFILESEARCHPATH")            = nil
libXt.so.6->getenv("XTAPPPEEKEVENT_SKIPTIMER")   = nil
libXt.so.6->getenv("XUSERFILESEARCHPATH")        = nil
--8<---------------cut here---------------end--------------->8---

Would one of these work better?  :-)

> --- a/gnu/system.scm
> +++ b/gnu/system.scm
> @@ -419,6 +419,31 @@ export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/m
>  export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
>  export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
>  export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
> +export XFILESEARCHPATH=\"$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:\\
> +$HOME/.guix-profile/share/X11/%l/%T/%N%C%S:\\
> +$HOME/.guix-profile/share/X11/%T/%N%C%S:\\
> +$HOME/.guix-profile/share/X11/%L/%T/%N%S:\\
> +$HOME/.guix-profile/share/X11/%l/%T/%N%S:\\
> +$HOME/.guix-profile/share/X11/%T/%N%S:\\
> +$HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:\\
> +$HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:\\
> +$HOME/.guix-profile/lib/X11/%T/%N%C%S:\\
> +$HOME/.guix-profile/lib/X11/%L/%T/%N%S:\\
> +$HOME/.guix-profile/lib/X11/%l/%T/%N%S:\\
> +$HOME/.guix-profile/lib/X11/%T/%N%S:\\
> +/run/current-system/profile/share/X11/%L/%T/%N%C%S:\\
> +/run/current-system/profile/share/X11/%l/%T/%N%C%S:\\
> +/run/current-system/profile/share/X11/%T/%N%C%S:\\
> +/run/current-system/profile/share/X11/%L/%T/%N%S:\\
> +/run/current-system/profile/share/X11/%l/%T/%N%S:\\
> +/run/current-system/profile/share/X11/%T/%N%S:\\
> +/run/current-system/profile/lib/X11/%L/%T/%N%C%S:\\
> +/run/current-system/profile/lib/X11/%l/%T/%N%C%S:\\
> +/run/current-system/profile/lib/X11/%T/%N%C%S:\\
> +/run/current-system/profile/lib/X11/%L/%T/%N%S:\\
> +/run/current-system/profile/lib/X11/%l/%T/%N%S:\\
> +/run/current-system/profile/lib/X11/%T/%N%S\"

That’s unreasonable IMO.

Is this motivated by the broken ctrl-click in xterm?  That thing used to
work, I wonder what happened.

Thanks for investigating!

Ludo’.
Ludovic Courtès - Nov. 29, 2016, 2:34 p.m.
John Darrington <john@darrington.wattle.id.au> skribis:

>     
>     > * gnu/system.scm (operating-system-etc-service): Add new environment
>     variable:
>     
>     The guix.texi change is missing from the log.
>
> Thanks for noticing.
>     
>     > diff --git a/doc/guix.texi b/doc/guix.texi
>     > index e64c361..9d133bb 100644
>     > --- a/doc/guix.texi
>     > +++ b/doc/guix.texi
>     > @@ -1209,6 +1209,36 @@ data in the right format.
>     >  This is important because the locale data format used by different libc
>     >  versions may be incompatible.
>     >  
>     > address@hidden X Window System
>     > address@hidden XFILESEARCHPATH
>     > address@hidden @code{Xt}
>     > address@hidden X Toolkit Intrinsics
>     > address@hidden @command{xterm}
>     > +
>     > +If you intend to use X Toolkit Intrinsics client applications such
>     > +as @command{xterm} then you should define the @code{XFILESEARCHPATH}
>     > +environment variable:
>     > +
>     > address@hidden
>     > +$ export XFILESEARCHPATH="$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:
>     > +  $HOME/.guix-profile/share/X11/%l/%T/%N%C%S:
>     > +  $HOME/.guix-profile/share/X11/%T/%N%C%S:
>     > +  $HOME/.guix-profile/share/X11/%L/%T/%N%S:
>     > +  $HOME/.guix-profile/share/X11/%l/%T/%N%S:
>     > +  $HOME/.guix-profile/share/X11/%T/%N%S:
>     > +  $HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:
>     > +  $HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:
>     > +  $HOME/.guix-profile/lib/X11/%T/%N%C%S:
>     > +  $HOME/.guix-profile/lib/X11/%L/%T/%N%S:
>     > +  $HOME/.guix-profile/lib/X11/%l/%T/%N%S:
>     > +  $HOME/.guix-profile/lib/X11/%T/%N%S"
>     > address@hidden example
>     
>     Seriously?!  I mean, we can reasonably ask people to do that, can we?
>     Is there another way?
>
> *shrug?* It's one more variable to set. Granted it's a long one.  But it's
> not *us* that's asking them to do it.  We are merely passing along advice
> from the Xt lib developers (see below).   If people want to use Xt then
> that's what they're supposed to do.

Fortunately people don’t “want” to use Xt nowadays.  ;-)

At any rate, I’m surprised this is so involved.

>     > +export XFILESEARCHPATH=\"$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/share/X11/%l/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/share/X11/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/share/X11/%L/%T/%N%S:\\
>     > +$HOME/.guix-profile/share/X11/%l/%T/%N%S:\\
>     > +$HOME/.guix-profile/share/X11/%T/%N%S:\\
>     > +$HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/lib/X11/%T/%N%C%S:\\
>     > +$HOME/.guix-profile/lib/X11/%L/%T/%N%S:\\
>     > +$HOME/.guix-profile/lib/X11/%l/%T/%N%S:\\
>     > +$HOME/.guix-profile/lib/X11/%T/%N%S:\\
>     > +/run/current-system/profile/share/X11/%L/%T/%N%C%S:\\
>     > +/run/current-system/profile/share/X11/%l/%T/%N%C%S:\\
>     > +/run/current-system/profile/share/X11/%T/%N%C%S:\\
>     > +/run/current-system/profile/share/X11/%L/%T/%N%S:\\
>     > +/run/current-system/profile/share/X11/%l/%T/%N%S:\\
>     > +/run/current-system/profile/share/X11/%T/%N%S:\\
>     > +/run/current-system/profile/lib/X11/%L/%T/%N%C%S:\\
>     > +/run/current-system/profile/lib/X11/%l/%T/%N%C%S:\\
>     > +/run/current-system/profile/lib/X11/%T/%N%C%S:\\
>     > +/run/current-system/profile/lib/X11/%L/%T/%N%S:\\
>     > +/run/current-system/profile/lib/X11/%l/%T/%N%S:\\
>     > +/run/current-system/profile/lib/X11/%T/%N%S\"
>     
>     That’s unreasonable IMO.
>
> This is merely the default value that the Xt library sets, but I
> have simply substituted "/usr" with "$HOME/.guix-profile" and
> repeated it substituting "/run/current-system/profile".
> It is a large string, but why is that a problem?

It’s ugly, there’s duplication, and hackers will not dare to touch it.

> We can cut down on the size of this string iff we can somehow
> guarantee that no package ever ships a file in any of those locations.
>
> Some "solutions" (in my order of preference) are:
>
> * The size of the above list can be halved, by dropping either the
> .../lib/... or the .../share/... items - we just have to then make
> sure that no package ships resource files in the one we drop.  Historically,
> resource files were always in .../lib (as still are all official
> sources from x.org) but recently third party packages have started
> putting them in .../share.
>
> * I *think* we could also get away with further reducing the set to 
>     "$HOME/.guix-profile/lib/X11/%T/%N%S:
>     /run/current-system/profile/lib/X11/%T/%N%S"
> because, all the Xt dependent packages I've seen so far, put their
> resource files there.  However, we cannot know what might get added
> in the future.

Right, if we do both, that’s already much better.

> * Hack the hard coded defaults in the libXt source to use the profile
> settings instead of /usr

Maybe we should just do that, no?  It’d be a local change, it would
achieve the same effect, and it would provide a good default.

WDYT?

I suppose there’s trickiness due to the fact that it’s C and we have to
concatenate strings…

> * Do what we had before:  Wrap *every* program which uses libXt in
> a script setting XAPPLRESDIR - This is sure to annoy users because
> it would override any XUSERFILESEARCHPATH they had set themselves.

Doesn’t sound great.

>     Is this motivated by the broken ctrl-click in xterm?  That thing used to
>     work, I wonder what happened.
>
> Xterm has never worked properly for me under GuixSD.  It "worked" under
> Guix on Debian, presumably because it found the resource files from
> the native installation.
>
> Xterm not working was what prompted me to find out the cause.
> But it will affect all and every package which provides X resource
> files as a shipped file.
>
> Anyway my general opinion is, that I agree that the value of this variable
> is rather long, but:
> 1. I don't see why that is a problem.
> 2. It is how the X Consortium intends and recommends it to be used.
> 3. A competent user will not be intimidated by it.
> 4. A naive user will never be aware of it anyway.
>
>
> For background information, see:
>
> * http://www.faqs.org/faqs/Xt-FAQ
> * The man page for XtResolvePathname
> * The file specs/CH11.xml in the libXt source.

OK.  Thanks for the info and everything!

Ludo’.
John Darrington - Nov. 29, 2016, 6:16 p.m.
On Tue, Nov 29, 2016 at 03:34:11PM +0100, Ludovic Court??s wrote:
     John Darrington <john@darrington.wattle.id.au> skribis:

     > We can cut down on the size of this string iff we can somehow
     > guarantee that no package ever ships a file in any of those locations.
     >
     > Some "solutions" (in my order of preference) are:
     >
     > * The size of the above list can be halved, by dropping either the
     > .../lib/... or the .../share/... items - we just have to then make
     > sure that no package ships resource files in the one we drop.  Historically,
     > resource files were always in .../lib (as still are all official
     > sources from x.org) but recently third party packages have started
     > putting them in .../share.
     >
     > * I *think* we could also get away with further reducing the set to 
     >     "$HOME/.guix-profile/lib/X11/%T/%N%S:
     >     /run/current-system/profile/lib/X11/%T/%N%S"
     > because, all the Xt dependent packages I've seen so far, put their
     > resource files there.  However, we cannot know what might get added
     > in the future.
     
     Right, if we do both, that???s already much better.
     
     > * Hack the hard coded defaults in the libXt source to use the profile
     > settings instead of /usr
     
     Maybe we should just do that, no?  It???d be a local change, it would
     achieve the same effect, and it would provide a good default.
     
     WDYT?

It sounds unreliable to me.  What would we set it to?
$GUIX_PROFILE/...  $HOME/.guix-profile/... /run/current-system/profile/...
There's no guarantee that the current profile is any of those.

Something similar to the first solution seems prefereable to me.  Maybe:

 Set XFILESEARCHPATH to "$HOME/.guix-profile/lib/X11/%T/%N%S:/run/current-system/profile/lib/X11/%T/%N%S"
  (we can substitute "share" for "lib" if we want to keep the FHS people happy).

 Then we audit all users of libxt to make sure they put their resource files in lib/X11/app-defaults.
 Most packages have a --with-app-defaults configure option (which currently we are in many cases
 either not using or misusing).

 We could also consider adding a build stage to make sure that packages which depend on libXt put
 their resource files in the "right" place.
Ludovic Courtès - Nov. 29, 2016, 9:42 p.m.
John Darrington <john@darrington.wattle.id.au> skribis:

> On Tue, Nov 29, 2016 at 03:34:11PM +0100, Ludovic Court??s wrote:
>      John Darrington <john@darrington.wattle.id.au> skribis:
>
>      > We can cut down on the size of this string iff we can somehow
>      > guarantee that no package ever ships a file in any of those locations.
>      >
>      > Some "solutions" (in my order of preference) are:
>      >
>      > * The size of the above list can be halved, by dropping either the
>      > .../lib/... or the .../share/... items - we just have to then make
>      > sure that no package ships resource files in the one we drop.  Historically,
>      > resource files were always in .../lib (as still are all official
>      > sources from x.org) but recently third party packages have started
>      > putting them in .../share.
>      >
>      > * I *think* we could also get away with further reducing the set to 
>      >     "$HOME/.guix-profile/lib/X11/%T/%N%S:
>      >     /run/current-system/profile/lib/X11/%T/%N%S"
>      > because, all the Xt dependent packages I've seen so far, put their
>      > resource files there.  However, we cannot know what might get added
>      > in the future.
>      
>      Right, if we do both, that???s already much better.
>      
>      > * Hack the hard coded defaults in the libXt source to use the profile
>      > settings instead of /usr
>      
>      Maybe we should just do that, no?  It???d be a local change, it would
>      achieve the same effect, and it would provide a good default.
>      
>      WDYT?
>
> It sounds unreliable to me.  What would we set it to?
> $GUIX_PROFILE/...  $HOME/.guix-profile/... /run/current-system/profile/...
> There's no guarantee that the current profile is any of those.

Maybe, but that would have the same effect as setting the environment
variable to that value, wouldn’t it?

> Something similar to the first solution seems prefereable to me.  Maybe:
>
>  Set XFILESEARCHPATH to "$HOME/.guix-profile/lib/X11/%T/%N%S:/run/current-system/profile/lib/X11/%T/%N%S"
>   (we can substitute "share" for "lib" if we want to keep the FHS people happy).

How did you manage to shorten it that much?  It’s much less intimidating
now.  :-)

>  Then we audit all users of libxt to make sure they put their resource files in lib/X11/app-defaults.
>  Most packages have a --with-app-defaults configure option (which currently we are in many cases
>  either not using or misusing).
>
>  We could also consider adding a build stage to make sure that packages which depend on libXt put
>  their resource files in the "right" place.

Sounds reasonable.

Ludo’.
John Darrington - Nov. 30, 2016, 5:36 a.m.
On Tue, Nov 29, 2016 at 10:42:49PM +0100, Ludovic Court??s wrote:
     John Darrington <john@darrington.wattle.id.au> skribis:
     
     >      > * Hack the hard coded defaults in the libXt source to use the profile
     >      > settings instead of /usr
     >      
     >      Maybe we should just do that, no?  It???d be a local change, it would
     >      achieve the same effect, and it would provide a good default.
     >      
     >
     > It sounds unreliable to me.  What would we set it to?
     > $GUIX_PROFILE/...  $HOME/.guix-profile/... /run/current-system/profile/...
     > There's no guarantee that the current profile is any of those.
     
     Maybe, but that would have the same effect as setting the environment
     variable to that value, wouldn???t it?

Except that the environment variable solution is easier for users to override. 
     
     > Something similar to the first solution seems prefereable to me.  Maybe:
     >
     >  Set XFILESEARCHPATH to "$HOME/.guix-profile/lib/X11/%T/%N%S:/run/current-system/profile/lib/X11/%T/%N%S"
     >   (we can substitute "share" for "lib" if we want to keep the FHS people happy).
     
     How did you manage to shorten it that much?  

Simply by assuming that nobody ever installs resource files outside these locations.
If anybody ever does - then things will break.
     
     >  Then we audit all users of libxt to make sure they put their resource files in lib/X11/app-defaults.
     >  Most packages have a --with-app-defaults configure option (which currently we are in many cases
     >  either not using or misusing).
     >
     >  We could also consider adding a build stage to make sure that packages which depend on libXt put
     >  their resource files in the "right" place.
     
     Sounds reasonable.

All in all, it sounds like a lot of work in the short time - but it might be worth it.
I'll see what I can do (and if it has a chance of working).

J'

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index e64c361..9d133bb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1209,6 +1209,36 @@  data in the right format.
 This is important because the locale data format used by different libc
 versions may be incompatible.
 
+@subsection X Window System
+@vindex XFILESEARCHPATH
+@vindex @code{Xt}
+@vindex X Toolkit Intrinsics
+@vindex @command{xterm}
+
+If you intend to use X Toolkit Intrinsics client applications such
+as @command{xterm} then you should define the @code{XFILESEARCHPATH}
+environment variable:
+
+@example
+$ export XFILESEARCHPATH="$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:
+  $HOME/.guix-profile/share/X11/%l/%T/%N%C%S:
+  $HOME/.guix-profile/share/X11/%T/%N%C%S:
+  $HOME/.guix-profile/share/X11/%L/%T/%N%S:
+  $HOME/.guix-profile/share/X11/%l/%T/%N%S:
+  $HOME/.guix-profile/share/X11/%T/%N%S:
+  $HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:
+  $HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:
+  $HOME/.guix-profile/lib/X11/%T/%N%C%S:
+  $HOME/.guix-profile/lib/X11/%L/%T/%N%S:
+  $HOME/.guix-profile/lib/X11/%l/%T/%N%S:
+  $HOME/.guix-profile/lib/X11/%T/%N%S"
+@end example
+
+@noindent
+This (rather long) definition provides the search path which the @code{Xt}
+library uses to search for resource files and other files needed for correct
+running of applications.
+
 @subsection X11 Fonts
 
 @cindex fonts
diff --git a/gnu/system.scm b/gnu/system.scm
index 4e57f97..729a1a0 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -419,6 +419,31 @@  export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/m
 export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
 export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
 export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
+export XFILESEARCHPATH=\"$HOME/.guix-profile/share/X11/%L/%T/%N%C%S:\\
+$HOME/.guix-profile/share/X11/%l/%T/%N%C%S:\\
+$HOME/.guix-profile/share/X11/%T/%N%C%S:\\
+$HOME/.guix-profile/share/X11/%L/%T/%N%S:\\
+$HOME/.guix-profile/share/X11/%l/%T/%N%S:\\
+$HOME/.guix-profile/share/X11/%T/%N%S:\\
+$HOME/.guix-profile/lib/X11/%L/%T/%N%C%S:\\
+$HOME/.guix-profile/lib/X11/%l/%T/%N%C%S:\\
+$HOME/.guix-profile/lib/X11/%T/%N%C%S:\\
+$HOME/.guix-profile/lib/X11/%L/%T/%N%S:\\
+$HOME/.guix-profile/lib/X11/%l/%T/%N%S:\\
+$HOME/.guix-profile/lib/X11/%T/%N%S:\\
+/run/current-system/profile/share/X11/%L/%T/%N%C%S:\\
+/run/current-system/profile/share/X11/%l/%T/%N%C%S:\\
+/run/current-system/profile/share/X11/%T/%N%C%S:\\
+/run/current-system/profile/share/X11/%L/%T/%N%S:\\
+/run/current-system/profile/share/X11/%l/%T/%N%S:\\
+/run/current-system/profile/share/X11/%T/%N%S:\\
+/run/current-system/profile/lib/X11/%L/%T/%N%C%S:\\
+/run/current-system/profile/lib/X11/%l/%T/%N%C%S:\\
+/run/current-system/profile/lib/X11/%T/%N%C%S:\\
+/run/current-system/profile/lib/X11/%L/%T/%N%S:\\
+/run/current-system/profile/lib/X11/%l/%T/%N%S:\\
+/run/current-system/profile/lib/X11/%T/%N%S\"
+
 
 # Ignore the default value of 'PATH'.
 unset PATH