unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59474: Guix Home generated .profile sets XDG_ vars that break GDM+Gnome login on foreign distros
@ 2022-11-22  6:02 Matt Armstrong
  2022-11-22  7:09 ` Liliana Marie Prikler
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Armstrong @ 2022-11-22  6:02 UTC (permalink / raw)
  To: 59474

I am experimenting with Guix Home on Debian Testing, using GDM+Gnome.
The .profile generated by "guix home reconfigure" broke logging in to
the Gnome desktop.  The gnome session would die, failing to initialize
what it considered to be essential things, and return to the login
screen I could log in to a tty, and was able to undo the new .profile
and get back to a working system.

The home-configuration.scm I used was generated by "guix home import"
and was quite simple:

----------------------------------------------------------------------
(use-modules (gnu home)
             (gnu packages)
             (gnu services)
             (guix gexp)
             (gnu home services shells))

(home-environment
  ;; Below is the list of packages that will show up in your
  ;; Home profile, under ~/.guix-home/profile.
  (packages (specifications->packages (list "glibc-locales")))

  ;; Below is the list of Home services.  To search for available
  ;; services, run 'guix home search KEYWORD' in a terminal.
  (services
   (list (service home-bash-service-type
                  (home-bash-configuration
                   (aliases '(("ls" . "ls --color=auto")))
                   (bashrc (list (local-file ".bashrc" "bashrc")))
                   (bash-logout (list (local-file ".bash_logout"
                                                  "bash_logout"))))))))
----------------------------------------------------------------------

Note: a stock GDM+Gnome setup runs the user's login shell when logging
in via the GDM display manager, and this shell execs
gnome-session-binary.  This doesn't necessarily happen with other
display managers or other desktop environments, so on those systems the
Guix Home .profile may not even run before the DE is initialized.
Nearly all of my time debugging this was spent figuring this out!  :-)

The .profile file generated by Guix Home is this:

----------------------------------------------------------------------
HOME_ENVIRONMENT=$HOME/.guix-home
. $HOME_ENVIRONMENT/setup-environment
$HOME_ENVIRONMENT/on-first-login
----------------------------------------------------------------------

The first thing I see is that $HOME/.guix-home/seutp-environment is
modifying various XDG_ variables incorrectly.  It prepends new values
without honor the variable's default value if it doesn't happen to be
set already.

For example, if XDG_DATA_DIRS is not set its default value is
"/usr/local/share/:/usr/share/".

But .guix-home/setup-environment will instead prepend a value without
checking, leaving XDG_DATA_DIRS set incorrectly to
"$HOME/.guix-home/profile/share:" when it should be
"$HOME/.guix-home/profile/share:/usr/local/share/:/usr/share/".

See this code in setup-environment:

case $XDG_DATA_DIRS in
  *$HOME_ENVIRONMENT/profile/share*) ;;
  *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
esac

The correct idiom is this:

XDG_DATA_DIRS=PATH_TO_PREPEND:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}

or

XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}:PATH_TO_APPEND

The above is what I see in various Nix and Snap configuration files.

Because I have a few other things installed that modify XDG_DATA_DIRS
before Guix Home does, Guix Home doesn't break that particular variable.

It did break XDG_CONFIG_DIRS, since Guix Home was setting it to
"$HOME/.guix-home/profile/etc/xdg:".  I worked around this problem by
running this code before Guix Home's .profile:

    # Note: when XDG_CONFIG_DIRS is not set Guix home sets
    # XDG_CONFIG_DIRS="$HOME/.guix-home/profile/etc/xdg:", which removes
    # the default "/etc/xdg" value.
    if [[ -z $XDG_CONFIG_DIRS ]]; then
        XDG_CONFIG_DIRS=/etc/xdg
    fi

    # Note: when XDG_DATA_DIRS is not set Guix home sets
    # XDG_DATA_DIRS="$HOME/.guix-home/profile/share:", which removes the
    # default "/usr/local/share:/usr/share" value.
    if [[ -z $XDG_DATA_DIRS ]]; then
        XDG_DATA_DIRS="/usr/local/share:/usr/share"
    fi

I have other more minor quibbles about how Guix Home handles XDG values:

XDG_STATE_HOME is set to a non-standard value.  In the current XDG Base
Directory Specification it defaults to "$HOME/.local/state", but Guix
Home sets it to "$HOME/.local/var/lib".  On a foreign distro this is
going to cause some disruption when a user switches to Guix Home, or
switches away.

XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
variable instead?  (if it ever does become a standard XDG variable, its
default may not be the same one picked by Guix Home, causing the same
issue as above).

Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to do
-- it is the job of whatever logs the user in.

XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their defaults
unnecessarily.

I modified my personal config by unsetting XDG_STATE_HOME, XDG_LOG_HOME,
XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_DATA_HOME if Guix Home left
them set to their default values (in the case of XDG_STATE_HOME I unset
it unconditionally).




^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#59474: Guix Home generated .profile sets XDG_ vars that break GDM+Gnome login on foreign distros
  2022-11-22  6:02 bug#59474: Guix Home generated .profile sets XDG_ vars that break GDM+Gnome login on foreign distros Matt Armstrong
@ 2022-11-22  7:09 ` Liliana Marie Prikler
  0 siblings, 0 replies; 2+ messages in thread
From: Liliana Marie Prikler @ 2022-11-22  7:09 UTC (permalink / raw)
  To: 59474

Am Montag, dem 21.11.2022 um 22:02 -0800 schrieb Matt Armstrong:
> The first thing I see is that $HOME/.guix-home/seutp-environment is
> modifying various XDG_ variables incorrectly.  It prepends new values
> without honor the variable's default value if it doesn't happen to be
> set already.
This is a known problem with Debian.  Unlike Ubuntu, which relies on
Flatpak and Snaps for its basic operations, Debian doesn't and hence
hasn't set up these variables explicitly.  Note that this isn't unique
to Guix Home or even just Guix.

> For example, if XDG_DATA_DIRS is not set its default value is
> "/usr/local/share/:/usr/share/".
None of these directories exist in Guix System.  Assuming them would be
a fault.  Note that the install script you're meant to use already
initializes these variables since July [1].

> XDG_STATE_HOME is set to a non-standard value.  In the current XDG
> Base Directory Specification it defaults to "$HOME/.local/state", but
> Guix Home sets it to "$HOME/.local/var/lib".
This is a genuine bug with Guix Home.

> XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
> should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
> variable instead?  (if it ever does become a standard XDG variable,
> its default may not be the same one picked by Guix Home, causing the
> same issue as above).
Another genuine bug with Guix Home, although the variable does predate
our support for XDG_STATE_HOME.  I suggest finding all uses of this
variable in Guix Home and replacing them accordingly.

> Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to
> do -- it is the job of whatever logs the user in.
I'm unsure about that one.

> XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their
> defaults unnecessarily.
Explicit is better than implicit.

Cheers


[1]
http://git.savannah.gnu.org/cgit/guix.git/commit/?id=23aafc800c9e678662766440916449ec5bbce830





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-22 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  6:02 bug#59474: Guix Home generated .profile sets XDG_ vars that break GDM+Gnome login on foreign distros Matt Armstrong
2022-11-22  7:09 ` Liliana Marie Prikler

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).