Message ID | c8f5f8b21bc299011bd598e9bbdd3d19999d1071.1655528190.git.philip@philipmcgrath.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2790127BBEA; Sat, 18 Jun 2022 06:26:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9F47D27BBE9 for <patchwork@mira.cbaines.net>; Sat, 18 Jun 2022 06:26:17 +0100 (BST) Received: from localhost ([::1]:50338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) id 1o2QyO-0006Fn-Qe for patchwork@mira.cbaines.net; Sat, 18 Jun 2022 01:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1o2QyA-0006Fd-FT for guix-patches@gnu.org; Sat, 18 Jun 2022 01:26:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1o2QyA-0006z4-3l for guix-patches@gnu.org; Sat, 18 Jun 2022 01:26:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1o2Qy9-0006zC-Vc; Sat, 18 Jun 2022 01:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56050] [PATCH] home: services: environment-variables: Fix XDG base directories. Resent-From: Philip McGrath <philip@philipmcgrath.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: philip@philipmcgrath.com, guix-patches@gnu.org Resent-Date: Sat, 18 Jun 2022 05:26:01 +0000 Resent-Message-ID: <handler.56050.B.165552993626819@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56050 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56050@debbugs.gnu.org Cc: Philip McGrath <philip@philipmcgrath.com> X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Philip McGrath <philip@philipmcgrath.com> Received: via spool by submit@debbugs.gnu.org id=B.165552993626819 (code B ref -1); Sat, 18 Jun 2022 05:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 18 Jun 2022 05:25:36 +0000 Received: from localhost ([127.0.0.1]:47392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1o2Qxj-0006yV-Ud for submit@debbugs.gnu.org; Sat, 18 Jun 2022 01:25:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:57828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <philip@philipmcgrath.com>) id 1o2Qxf-0006yK-ME for submit@debbugs.gnu.org; Sat, 18 Jun 2022 01:25:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <philip@philipmcgrath.com>) id 1o2Qxf-0006F2-Eh for guix-patches@gnu.org; Sat, 18 Jun 2022 01:25:31 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:33389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <philip@philipmcgrath.com>) id 1o2Qxc-0006mP-1Q for guix-patches@gnu.org; Sat, 18 Jun 2022 01:25:29 -0400 Received: by mail-qv1-xf30.google.com with SMTP id 89so9250331qvc.0 for <guix-patches@gnu.org>; Fri, 17 Jun 2022 22:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QjwKyJ2e+bvjFXk+UXmFvz9mwHUCHBZquJEGkyogtfA=; b=FwSFe5aXL1rKQp2PHmWJ+fIuqEZCDvyvIm1ZgsdYjtLMGO8RswKrEYabEuZ8Gv1kzm ips2tBjnFnXXo6e1tc2lJkkAR8VSRXTfLkvw4XWYgNBaNF5FmVCL7SpRafZxmlJfC6/P j27cklAQujgOEH8HhXzd2wyVXw0RzTBcT2u8KBlUBHXWsr+8qLE44BWZBAxJBF0kp8ao QC4+1XkNyHIQxRi9MeAL1ylgMrx5VeH59z5UJdfMWqxKmm9jqDq1Lp60o/O40wCqZyAt hI7hIcykjAv6pkI+j3/Unk41exhmP+2faSwn4Mx2hR2ESREJzRN51/lTdXUGLQF3km1I G2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QjwKyJ2e+bvjFXk+UXmFvz9mwHUCHBZquJEGkyogtfA=; b=V+4utEVi+p2so8s1I9RUcAipM9dIRL6ZCxh2USodtErosdlGjOkgWbhBvN7ybMFMBU xSxIFmH2YGo3UEm1mgNHbVuH92EuVkVna9KUua5yVzKEY59tFhKPBiMIA2s1ZwziyNT4 HSclKVdEesg3keX2ydl4nW15pdUz94mGcoR/bEKodnzWgxlln/fDepb+RPfhk3nr1K3p usFJJzWjBHEF715rY9p5Lf7yC1VZLQaIc1HH12pIeph34ng5pMAEUWdLgAoxU5voi9pZ Ngr+Qw1b7VsE6mbL8W9wqEMEvG3m1nqWTqz201d7/d6SrP1HODAQykaW/QIiOyev5u6k q2ow== X-Gm-Message-State: AJIora9VeGtapEtOWQ6BTndMrAmGnjd9aTbtPxPevHB/bSW8UdMku2fi P+F/1qw/MenetcmKg3aRVzJjjaG8d7tC9tVpkDc= X-Google-Smtp-Source: AGRyM1sbX938k9eUZxKz3mNjRRFjNzWMoGRRCvQUAX+VC2XTunGntBDFYzETRqPtPZ7OIGRNOT8Y3w== X-Received: by 2002:ad4:5cab:0:b0:464:643b:1099 with SMTP id q11-20020ad45cab000000b00464643b1099mr11205147qvh.95.1655529925033; Fri, 17 Jun 2022 22:25:25 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id ay35-20020a05620a17a300b006a716fed4d6sm5568971qkb.50.2022.06.17.22.25.24 for <guix-patches@gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jun 2022 22:25:24 -0700 (PDT) From: Philip McGrath <philip@philipmcgrath.com> Date: Sat, 18 Jun 2022 01:25:23 -0400 Message-Id: <c8f5f8b21bc299011bd598e9bbdd3d19999d1071.1655528190.git.philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: permerror client-ip=2607:f8b0:4864:20::f30; envelope-from=philip@philipmcgrath.com; helo=mail-qv1-xf30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#56050] home: services: environment-variables: Fix XDG base directories.
|
|
Commit Message
Philip McGrath
June 18, 2022, 5:25 a.m. UTC
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. --- MANPATH and INFOPATH don't have this problem because they have well-defined behavior for a trailing ":". XCURSOR_PATH, on the other hand, does seem to have a similar problem. In my KDE Plasma Wayland session, at least, omiting the default caused the cursor to disappear when hovering over the border of a window. I could fix this on my Debian-based distribution by putting: export XCURSOR_PATH="${XCURSOR_PATH:-/usr/share/icons:/usr/share/pixmaps}" in a file under "/etc/profile.d", but I'm not sure if that default is truly portable even among FHS-based distros. For example, it sounds like Gentoo uses "/usr/share/cursors/xorg-x11". So I haven't tried to address XCURSOR_PATH for now. -Philip gnu/home/services.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) base-commit: 3154b582567539d8d607344fbd03a3d8456f66cb
Comments
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. Thanks, Ludo’.
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
Hi Philip, Philip McGrath <philip@philipmcgrath.com> skribis: > 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. Yes, changing /etc/profile.d/guix.sh sounds better: it allows us to provide a solution specifically for foreign distros. This file is created by ‘etc/guix-install.sh’, the installation script given at <https://guix.gnu.org/manual/en/html_node/Binary-Installation.html>. > One catch is that, right now, this is what was installed for me into /etc/profile.d/guix.sh: [...] > 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? Yes, that too! We should change it so that it checks ~/.guix-home/profile and ~/.guix-profile (in that order) and picks the right one. Would you like to give it a try? Thanks, Ludo’.
Hi, Here is a v2! I've changed the ‘/etc/profile.d/guix.sh’ generated by ‘etc/guix-install.sh’ to initialize all of the XDG base directory variables---some seem less likely to cause problems, but it should be harmless to make them all explicit---and to check for ‘~/.guix-home/profile’ before ‘~/.guix-profile’ when looking for the default profile. I still haven't done anything here about `XCURSOR_PATH`, but I've looked into the situation more, and there is a Chromium bug [1] that confirms what I previously thought: the default search path [2] can be overridden by configuring libXcursor with `--with-cursorpath=`, and Gentoo, at least, does so [3]. (So far, Gentoo is the only distro I've found that does so.) It seems like the only way to find out the system's default path is, with `XCURSOR_PATH` unset, to `dlopen` libXcursor and call `XcursorLibraryPath`. A further complication is that the default path: ~/.local/share/icons:~/.icons:/usr/share/icons:/usr/share/pixmaps contains both user-specific and system-wide locations, seemingly with no reliable way to interject between them. I think it would not be so bad to ignore this issue, and that's what I propose doing for now: unlike the problems with the XDG variables, which for me produced a black screen instead of a desktop environment, the only symptom of the missing `XCURSOR_PATH` for me was that my cursor disapeared when hovering over the edges of windows, rather than transforming into a bidirectional resize cursor. It might also be reasonable to initialize `XCURSOR_PATH` to "/usr/share/icons:/usr/share/pixmaps". Even Gentoo's default value for `XCURSOR_PATH` seems to include those directories. But I wonder if it really makes sense for `environment-variables->setup-environment-script` from `(gnu home services)` to always set `XCURSOR_PATH`. I, for one, don't have any cursors in `$HOME_ENVIRONMENT/profile/share/icons` (though I do have other kinds of icons in that path). If we just left `XCURSOR_PATH` alone, we could at least limit the problem to people who actually want to manage cursors with `guix home`. In any case, `XCURSOR_PATH` need not block these patches. -Philip [1]: https://bugs.chromium.org/p/chromium/issues/detail?id=1127712 [2]: https://gitlab.freedesktop.org/xorg/lib/libxcursor/-/blob/master/configure.ac#L70 [3]: https://gitweb.gentoo.org/repo/gentoo.git/tree/x11-libs/libXcursor/libXcursor-1.2.1.ebuild?id=b8516dc07a786a1aff6cd493376a7b2810a9a82c Philip McGrath (2): etc/guix-install.sh: Initialize XDG base directories. etc/guix-install.sh: Check for profile from 'guix home'. etc/guix-install.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) base-commit: 4a2f487740fc4a000480226fd25ff2452efa9012
diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 5ee3357792..ba14d8a119 100644 --- a/gnu/home/services.scm +++ 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/} ;; esac case $MANPATH in *$HOME_ENVIRONMENT/profile/share/man*) ;; @@ -220,7 +220,7 @@ (define (environment-variables->setup-environment-script vars) esac 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} ;; esac case $XCURSOR_PATH in *$HOME_ENVIRONMENT/profile/share/icons*) ;;