Nixpkgs: LightDM doesn't get global NixOS environment

Created on 9 Sep 2019  ·  10Comments  ·  Source: NixOS/nixpkgs

Describe the bug
I've noticed that we've wrapped lightdm-gtk-greeter in a ridiculous manner

and for elementary-greeter to even function properly I've had to do similar.

In particular, in elementary-greeter, it never has the proper theme applied etc.

I did some debugging on to what environment variables are set in the greeter session and what the contents of XDG_DATA_DIRS was with elementary-greeter:

Environment variables set

** Message: 21:11:56.153: Application.vala:55: XDG_CONFIG_HOME
** Message: 21:11:56.153: Application.vala:55: LANG
** Message: 21:11:56.153: Application.vala:55: GTK_DATA_PREFIX
** Message: 21:11:56.153: Application.vala:55: DISPLAY
** Message: 21:11:56.153: Application.vala:55: LIGHTDM_FROM_SERVER_FD
** Message: 21:11:56.153: Application.vala:55: NIX_GSETTINGS_OVERRIDES_DIR
** Message: 21:11:56.153: Application.vala:55: XDG_VTNR
** Message: 21:11:56.153: Application.vala:55: XDG_SESSION_ID
** Message: 21:11:56.153: Application.vala:55: XDG_GREETER_DATA_DIR
** Message: 21:11:56.153: Application.vala:55: USER
** Message: 21:11:56.153: Application.vala:55: TZDIR
** Message: 21:11:56.153: Application.vala:55: PWD
** Message: 21:11:56.153: Application.vala:55: NIX_PATH
** Message: 21:11:56.153: Application.vala:55: HOME
** Message: 21:11:56.153: Application.vala:55: XDG_SESSION_TYPE
** Message: 21:11:56.153: Application.vala:55: GTK_PATH
** Message: 21:11:56.153: Application.vala:55: XDG_DATA_DIRS
** Message: 21:11:56.153: Application.vala:55: GI_TYPELIB_PATH
** Message: 21:11:56.153: Application.vala:55: GIO_EXTRA_MODULES
** Message: 21:11:56.153: Application.vala:55: GDK_PIXBUF_MODULE_FILE
** Message: 21:11:56.154: Application.vala:55: SHELL
** Message: 21:11:56.154: Application.vala:55: XDG_SESSION_CLASS
** Message: 21:11:56.154: Application.vala:55: XCURSOR_THEME
** Message: 21:11:56.154: Application.vala:55: SHLVL
** Message: 21:11:56.154: Application.vala:55: XDG_SEAT
** Message: 21:11:56.154: Application.vala:55: LOCALE_ARCHIVE
** Message: 21:11:56.154: Application.vala:55: LOGNAME
** Message: 21:11:56.154: Application.vala:55: LIGHTDM_TO_SERVER_FD
** Message: 21:11:56.154: Application.vala:55: XDG_RUNTIME_DIR
** Message: 21:11:56.154: Application.vala:55: XAUTHORITY
** Message: 21:11:56.154: Application.vala:55: PATH
** Message: 21:11:56.154: Application.vala:55: GTK_EXE_PREFIX
** Message: 21:11:56.154: Application.vala:55: GST_PLUGIN_SYSTEM_PATH_1_0
** Message: 21:11:56.154: Application.vala:55: XCURSOR_PATH
** Message: 21:11:56.154: Application.vala:55: G_MESSAGES_DEBUG

XDG_DATA_DIRS

** Message: 21:11:56.152: Application.vala:50: /nix/store/dnnm9lv48kd10dm8870r1gy4kw7f70bf-elementary-greeter-unstable-2019-07-03/share
** Message: 21:11:56.152: Application.vala:50: /nix/store/fn0dmds7hkxmxszqfg4q71jqwdviw1yl-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10
** Message: 21:11:56.153: Application.vala:50: /nix/store/bcd3q7l0yaimyq8vvlf0iyma5f0ccv0b-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0
** Message: 21:11:56.153: Application.vala:50: /nix/store/cimrzkvfqlp2wiamlvmdrzf00v9qr5fj-elementary-settings-daemon-3.30.2/share/gsettings-schemas/elementary-settings-daemon-3.30.2
** Message: 21:11:56.153: Application.vala:50: /nix/store/5f8lpd3ix8nb36cnnk963wrjbva0jxxd-granite-5.2.3/share/gsettings-schemas/granite-5.2.3
** Message: 21:11:56.153: Application.vala:50: /nix/store/dxb2kw40q7yhxdp1v0x9sjkgfb4sln6h-mutter-3.28.4/share/gsettings-schemas/mutter-3.28.4
** Message: 21:11:56.153: Application.vala:50: /nix/store/fn0dmds7hkxmxszqfg4q71jqwdviw1yl-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10
** Message: 21:11:56.153: Application.vala:50: /nix/store/bcd3q7l0yaimyq8vvlf0iyma5f0ccv0b-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0
** Message: 21:11:56.153: Application.vala:50: /nix/store/cimrzkvfqlp2wiamlvmdrzf00v9qr5fj-elementary-settings-daemon-3.30.2/share/gsettings-schemas/elementary-settings-daemon-3.30.2
** Message: 21:11:56.153: Application.vala:50: /nix/store/5f8lpd3ix8nb36cnnk963wrjbva0jxxd-granite-5.2.3/share/gsettings-schemas/granite-5.2.3
** Message: 21:11:56.153: Application.vala:50: /nix/store/dxb2kw40q7yhxdp1v0x9sjkgfb4sln6h-mutter-3.28.4/share/gsettings-schemas/mutter-3.28.4
** Message: 21:11:56.153: Application.vala:50: /nix/store/fn0dmds7hkxmxszqfg4q71jqwdviw1yl-gtk+3-3.24.10/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/kbrkq3licn8vz1f5981ff9lsldry3cbz-cups-2.2.11/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/f8a6g4km56xzm7gzcf6vgsxfcximgrsl-elementary-icon-theme-5.0.4/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/mn9yacr0fs2mxpya7jfbwiaazcask5ld-hicolor-icon-theme-0.17/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/5f8lpd3ix8nb36cnnk963wrjbva0jxxd-granite-5.2.3/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/f03bzbdzfrqhbih7byn66h3nhlwwz41k-wingpanel-2.2.5-with-indicators/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/fn0dmds7hkxmxszqfg4q71jqwdviw1yl-gtk+3-3.24.10/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/kbrkq3licn8vz1f5981ff9lsldry3cbz-cups-2.2.11/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/f8a6g4km56xzm7gzcf6vgsxfcximgrsl-elementary-icon-theme-5.0.4/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/mn9yacr0fs2mxpya7jfbwiaazcask5ld-hicolor-icon-theme-0.17/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/5f8lpd3ix8nb36cnnk963wrjbva0jxxd-granite-5.2.3/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/f03bzbdzfrqhbih7byn66h3nhlwwz41k-wingpanel-2.2.5-with-indicators/share
** Message: 21:11:56.153: Application.vala:50: /nix/store/z0anl88fs9sw7l95irqbl9ypqjcsxbjy-elementary-gsettings-desktop-schemas/share/gsettings-schemas/elementary-gsettings-desktop-schemas

Notice how we're missing entries that set-environment script would have added like
/nix/var/nix/profiles/default/share:/run/current-system/sw/share.

Off the top of my head this causes issues like

  • not using the users theme
  • not using the users icons
  • never having the correct cursor theme
  • NIX_GSETTINGS_OVERRIDES_DIR won't do anything (it's not there)

This most importantly causes https://github.com/elementary/greeter/issues/318 which I only realized when wingpanel was transparent if ran in a pure nix-shell.

To Reproduce
Steps to reproduce the behavior:

  1. Patch your favorite lightdm greeter to spit out contents of XDG_DATA_DIRS and variables set
  2. Notice the global environment isn't set
  3. Experience a lot of side effects because of this

Expected behavior
Have the profiles environment variables in the greeter session.

bug nixos pantheon

All 10 comments

cc @hedning

I was also wondering why lightdm could never successfully run plymouth --ping even when I had it enabled

That's also because of this. PATH wasn't set at all for plymouth to be available.

/etc/set-environment isn't sourced when starting display-managers (or any other services for that matter). It's done straight from systemd with a fairly minimal environment:
https://github.com/NixOS/nixpkgs/blob/b27da0dde7e1ebe3e327c17160d1b03a11f9efe1/nixos/modules/services/x11/xserver.nix#L667-L670

I'm guessing there's three or four ways of fixing this:

  1. Add the necessary profile relative envs to the display-manager.service environment
  2. Add it to the greeter wrappers
  3. Use pam or systemd to add a basic environment (not sure if /etc/environment is sourced when running the display-manager, ie. if it's considered a user session, so might need to use pam)

1. might be the best bet?

But doesn't /etc/profile use set-environment?
Or do we not even touch that file and my mental documentation is dated 😅️

I'm guessing there's three or four ways of fixing this:

1. Add the necessary profile relative envs to the display-manager.service environment

2. Add it to the greeter wrappers

3. Use pam or systemd to add a basic environment (not sure if  `/etc/environment` is sourced when running the display-manager, ie. if it's considered a user session, so might need to use pam)
  1. might be the best bet?

I'm thinking 1 would fix it for LightDM, but could this also be an issue we'll have with gnome 3.34's systemd units? And I'm pretty sure in general then, so I guess something like 3 would be best.

Yeah, the services aren't normally run through bash (it's eg. done explicitly in emacs.service). GDM also has a really bare bones environment which is why we for instance do this in gnome-session:
https://github.com/NixOS/nixpkgs/blob/a10ba70aa22fef699d075f6704b850764b1e8208/pkgs/desktops/gnome-3/core/gnome-session/fix-paths.patch#L11

Not sure what's the general opinion of adding the basic NixOS paths etc. by default to systemd services.

we'll have with gnome 3.34's systemd units

Hmm, perhaps, haven't taken a crack at those yet.

To me it makes sense that services should have access to the default path and xdg vars, but it does make things less pure I guess :laughing:

Not sure what's the general opinion of adding the basic NixOS paths etc. by default to systemd services.

I'd say it's something we need to do because we already expect that environment.

And it seems maybe https://github.com/NixOS/nixpkgs/pull/67942 already implemented the option we need for this.

And it seems maybe #67942 already implemented the option we need for this.

Yeah, looks like the display managers should get some environment from pam, so that might be best. :+1:

Right, we'd basically have to make an identical call to environment.profileRelativeSessionVariables wherever environment.profileRelativeEnvVars is used.

We could drop things like
https://github.com/NixOS/nixpkgs/blob/a10ba70aa22fef699d075f6704b850764b1e8208/nixos/modules/services/x11/display-managers/gdm.nix#L146
and wrapping the greeters in that way, because it just looks pretty unpleasant :smile: .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthiasbeyer picture matthiasbeyer  ·  3Comments

spacekitteh picture spacekitteh  ·  3Comments

vaibhavsagar picture vaibhavsagar  ·  3Comments

yawnt picture yawnt  ·  3Comments

ob7 picture ob7  ·  3Comments