unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip McGrath <philip@philipmcgrath.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 56050@debbugs.gnu.org
Subject: [bug#56050] [PATCH] home: services: environment-variables: Fix XDG base directories.
Date: Thu, 23 Jun 2022 17:33:16 -0400	[thread overview]
Message-ID: <10145966.nUPlyArG6x@avalon> (raw)
In-Reply-To: <871qvg303w.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4254 bytes --]

On Wednesday, June 22, 2022 4:38:11 PM EDT Ludovic Courtès wrote:
> Philip McGrath <philip@philipmcgrath.com> skribis:
> > When the environment initialization script is run, XDG_DATA_DIRS and/or
> > XDG_CONFIG_DIRS may be empty or unset, in which case we must use their
> > respective defaults from the specification, rather than ending the value
> > with a trailing ":". For further discussion, see
> > <https://lists.gnu.org/archive/html/help-guix/2022-05/msg00147.html>.
> > 
> > * gnu/home/services.scm
> > (environment-variables->setup-environment-script): Use conditional
> > parameter expansion for XDG_DATA_DIRS and XDG_CONFIG_DIRS.
> 
> [...]
> 
> > +++ b/gnu/home/services.scm
> > @@ -208,7 +208,7 @@ (define
> > (environment-variables->setup-environment-script vars)> 
> >  case $XDG_DATA_DIRS in
> >  
> >    *$HOME_ENVIRONMENT/profile/share*) ;;
> > 
> > -  *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS
> > ;; +  *) export
> > XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:${XDG_DATA_DIRS:-/usr/local
> > /share/:/usr/share/} ;;
> What about doing it this way:
> 
>   export
> "XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share${XDG_DATA_DIRS:+:}$XDG_DATA_
> DIRS"
> 
> That would avoid adding /usr, which makes little sense for Guix and
> could lead to bad surprises on foreign distros, such as loading
> incompatible data from the host distro.
> 
> WDYT?
> 
> >  case $XDG_CONFIG_DIRS in
> >  
> >    *$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
> > 
> > -  *) export
> > XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFIG_DIRS ;; + 
> > *) export
> > XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:${XDG_CONFIG_DIRS:-/etc
> > /xdg} ;;
> Same question here, though /etc/xdg is a bit less problematic as it
> could exist on Guix System too.
> 

Unfortunately this doesn't work: on a foreign distro (concretely, for me, Kubuntu 22.04) when XDG_CONFIG_DIRS isn't set globally, this would expand equivalent to just:

    XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg

Arguably, that's slightly better than ending with a trailing ":", since the semantics of an empty element in or at the end of the path list doesn't seem to be defined by the specification. However, it leaves me with the same problem: SDDM can't find the configuration it needs to start my KDE Plasma session successfully.

I do see how /usr would not make a lot of sense for Guix System. Since those paths are written into the spec for empty or unset variables, it seems like Guix System probably should arrange for all of the XDG variables to be set to something non-empty very early, maybe in /etc/profile itself.

I based this patch on the file that gets installed as /etc/profile.d/guix.sh (I haven't found its source yet). Maybe we could leave this code alone if we change that file, instead? Then, both on Guix System and on foreign distros, some system-wide code would be responsible for initializing these search paths, and we could assume in contexts like this that they are explicitly set and not empty.

One catch is that, right now, this is what was installed for me into /etc/profile.d/guix.sh:

```
# _GUIX_PROFILE: `guix pull` profile
_GUIX_PROFILE="$HOME/.config/guix/current"
if [ -L $_GUIX_PROFILE ]; then
  export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
  # Export INFOPATH so that the updated info pages can be found
  # and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info
  # When INFOPATH is unset, add a trailing colon so that Emacs
  # searches 'Info-default-directory-list'.
  export INFOPATH="$_GUIX_PROFILE/share/info:$INFOPATH"
fi

# GUIX_PROFILE: User's default profile
GUIX_PROFILE="$HOME/.guix-profile"
[ -L $GUIX_PROFILE ] || return
GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
export GUIX_PROFILE GUIX_LOCPATH

[ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile"

# set XDG_DATA_DIRS to include Guix installations
export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
```

but $HOME/.guix-profile doesn't exist for me (only $HOME/.guix-home), so this script exits without setting GUIX_LOCPATH or XDG_DATA_DIRS. Maybe something about that should change?

-Philip

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-06-23 21:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18  5:25 [bug#56050] [PATCH] home: services: environment-variables: Fix XDG base directories Philip McGrath
2022-06-22 20:38 ` Ludovic Courtès
2022-06-23 21:33   ` Philip McGrath [this message]
2022-06-25 21:39     ` Ludovic Courtès
2022-07-04  2:35       ` [bug#56050] [PATCH v2 0/2] etc/guix-install.sh: Initialize " Philip McGrath
2022-07-04  2:35         ` [bug#56050] [PATCH v2 1/2] " Philip McGrath
2022-07-04  9:11           ` Ludovic Courtès
2022-07-04 16:36             ` Philip McGrath
2022-07-04 21:01               ` Ludovic Courtès
2022-07-04 20:18           ` [bug#56050] [PATCH] home: services: environment-variables: Fix " Ludovic Courtès
2022-07-04  2:35         ` [bug#56050] [PATCH v2 2/2] etc/guix-install.sh: Check for profile from 'guix home' Philip McGrath
2022-07-04  9:13           ` Ludovic Courtès
2022-07-12  6:44           ` Andrew Tropin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10145966.nUPlyArG6x@avalon \
    --to=philip@philipmcgrath.com \
    --cc=56050@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).