Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sway: gsettings executed from sway/config fails #67704

Closed
colemickens opened this issue Aug 29, 2019 · 12 comments · Fixed by #86960
Closed

sway: gsettings executed from sway/config fails #67704

colemickens opened this issue Aug 29, 2019 · 12 comments · Fixed by #86960

Comments

@colemickens
Copy link
Member

If one tries to use the Sway wiki's suggested fix for GTK3 app graphical configuration, they will find themselves failing in NixOS. I think I've tracked down why.

Background:

  1. GTK3 doesn't respect ~/.config/gtk-3.0/settings.ini, for certain settings, under Wayland.
  2. Sway recommends a script that calls gsettings set with values from settings.init to ensure the values in the dconf backend reflect the same values in the text file:

Executing the script manually, from a terminal under Sway, works as expected. When run from a command in ~/.config/sway/config as exec_always, it fails. I think this is because XDG_DATA_DIRS does not include the schema directories when Sway runs the command.

This is XDG_DATA_DIRS from a terminal under Sway:

/nix/store/7kdr875bhq5sgnh7x7xkkbbdq0a3qixv-termite-15/share:/nix/store/9v6jxyn1v2ncj4dnw317ibivzp8lkvzv-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/7066ihqk8zlcd77ccb50m445v6dsxkz7-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/9v6jxyn1v2ncj4dnw317ibivzp8lkvzv-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/7066ihqk8zlcd77ccb50m445v6dsxkz7-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/home/cole/.nix-profile/share:/etc/profiles/per-user/cole/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

But this is it when Sway executes it:

/home/cole/.nix-profile/share:/etc/profiles/per-user/cole/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

Additionally, if I try to do this from inside the script, it prints "no schemas installed" when run by sway:

echo "$(GSETTINGS_BACKEND=dconf gsettings get org.gnome.desktop.interface cursor-theme 2>&1)" >> ~/log

Upstream issue: swaywm/sway#4323 (sorta, the issue describe by OP seems somewhat different)

cc: @gnidorah @primeos

@primeos
Copy link
Member

primeos commented Aug 29, 2019

I think this is because XDG_DATA_DIRS does not include the schema directories when Sway runs the command.

Seems reasonable.

$XDG_DATA_DIRS differs in the terminal because termite uses wrapGAppsHook which adds a wrapper that looks like this:

#! /nix/store/xfghy8ixrhz3kyy6p724iv3cxji088dx-bash-4.4-p23/bin/bash -e
export GIO_EXTRA_MODULES='/nix/store/1i2824pmaclhcbddbk7r2yc7ni645x22-dconf-0.32.0-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GIO_EXTRA_MODULES='/nix/store/1i2824pmaclhcbddbk7r2yc7ni645x22-dconf-0.32.0-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GDK_PIXBUF_MODULE_FILE='/nix/store/9asda59pz0hg8bznxa64nx7n45v1szdz-librsvg-2.44.14/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'
export XDG_DATA_DIRS='/nix/store/inlknqkinymvskvigpj345mfyfdvichx-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/r3g9yn2cw6239szfq65q2cxw4cg35a81-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/inlknqkinymvskvigpj345mfyfdvichx-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/r3g9yn2cw6239szfq65q2cxw4cg35a81-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS
export XDG_DATA_DIRS='/nix/store/cp5g9b8rdq48zkqjlbnc47g3kq7l54bz-termite-15/share'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS
exec -a "$0" "/nix/store/cp5g9b8rdq48zkqjlbnc47g3kq7l54bz-termite-15/bin/.termite-wrapped"  "${extraFlagsArray[@]}" "$@"

If you use another terminal emulator you should see the unmodified $XDG_DATA_DIRS like Sway sees it.

We could fix this problem by doing something similar for Sway. However, I'm a bit concerned about the closure size as this affects all users, even if they're not using GTK3 applications. But since most users should have the dependencies already installed and Nix isn't very minimalistic anyway we can probably get away with it. But it might still be best to make this configurable and use conservative defaults. It might be best to split Sway into sway and sway-unwrapped (but I am open for other ideas, I didn't spend much though on it yet).

@FlorianFranzen
Copy link
Contributor

FlorianFranzen commented Sep 5, 2019

I made the missing gsettings schemas available from sway by computing the missing path like this:

schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";

And then exporting it to sway's environment by adding the following to sway's extraSessionCommands:

XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS

Now the org.gnome.desktop.interface schema can be accessed from sway.

@ghost ghost mentioned this issue Dec 8, 2019
10 tasks
@worldofpeace
Copy link
Contributor

cc @jtojnar

This has my 👀 because it seems like a simple issue.
Ref https://nixos.org/nixpkgs/manual/#sec-language-gnome, to anyone who hasn't read the newly added docs.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 9, 2019

The diagnosis is correct.

We solve the issue in GNOME Photos test by wrapping GSettings tool:

https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/installed-tests/gnome-photos.nix#L11-L25

The proper solution is #71079 using #54150

primeos added a commit that referenced this issue Dec 21, 2019
sway: refactor with a wrapper

This moves the wrapper functionality from the NixOS module to a new package
(wrapper) that wraps the original sway package (sway-unwrapped). Therefore it's
now also possible to properly use Sway on non-NixOS systems out of the box.

The new submodule for the wrapperFeatures makes it easy to extend the
functionality which should become useful in the future.

This also introduces a GTK wrapper feature to fix issues with icon/GTK themes,
e.g. when running waybar or wofi. This should also work for #67704. If not, we
might have to add some additional dependencies/arguments for this case.
@ghost
Copy link

ghost commented Dec 27, 2019

@colemickens Is your issue fixed by #75247 ?

@eoli3n
Copy link

eoli3n commented Jan 7, 2020

I tested, it works.

EDIT : I think i didn't test well, it seems not working
https://github.com/eoli3n/nix-config/blob/eb7910f5e68427004d096ebb9d160122c81cc061/modules/includes/sway.nix#L5
With unstable

@ymarkus
Copy link
Contributor

ymarkus commented May 5, 2020

For me, this issue is still open. Here is my sway configuration:

sway = {
  enable = true;
  extraPackages = with pkgs; [ some_packages ];
  wrapperFeatures.gtk = true;
  extraSessionCommands = "export MOZ_ENABLE_WAYLAND=1";
};

Is it a config issue on my side?

edit: some more information:
error message given by atom: GLib-GIO-ERROR **: 12:13:26.961: No GSettings schemas are installed on the system

$XDG_DATA_DIR as given by termite: /nix/store/7m99r1fx36zndgxrilg6kppg8k0d6pjb-termite-15/share:/nix/store/6yrlycwcnxlgg6bkhq4jvwmahyrj00id-gtk+3-3.24.17/share/gsettings-schemas/gtk+3-3.24.17:/nix/store/78x2nyfhhili5ijd6l74z3flj63p92s0-gsettings-desktop-schemas-3.36.0/share/gsettings-schemas/gsettings-desktop-schemas-3.36.0:/home/my_user/.nix-profile/share:/etc/profiles/per-user/my_user/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

$XDG_DATA_DIR as given by other terminals: /home/my_user/.nix-profile/share:/etc/profiles/per-user/my_user/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

@ghost
Copy link

ghost commented May 5, 2020

There might be a regression with the GTK wrapper for sway, @primeos what do you think of this ?

EDIT: I'm able to reproduce the issue, I'm currently working on this, I will submit a PR as soon as I figure out what's happening :)

@primeos
Copy link
Member

primeos commented May 5, 2020

There might be a regression with the GTK wrapper for sway, @primeos what do you think of this?

Don't know. I'm not using the GTK wrapper so far, but from this issue it looks like the GTK wrapper never fixed this problem.

From this thread it looks like we could e.g. solve this issue by adding gsettings-desktop-schemas to the build inputs of Sway's wrapper.nix (if withGtkWrapper = true). But I'm not sure what the best/preferred way to solve this is. Might e.g. be worth it to have a quick look at the X11 and GNOME modules and/or cc the team (or maybe the links from #67704 (comment) are already clear enough, I didn't have a closer look). A PR would be nice :) Thanks and good luck ;)

@ghost
Copy link

ghost commented May 5, 2020

After some digging, it seems that wrapGAppsHook is not applying a "full" context (as opposed to termite for instance) to sway.

generated wrapper for Sway:

export GIO_EXTRA_MODULES='/nix/store/4fq6w7ksq1dba80sxpdgzrxpd46kdjgq-dconf-0.36.0-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES

generate wrapper for Termite:

export GIO_EXTRA_MODULES='/nix/store/4fq6w7ksq1dba80sxpdgzrxpd46kdjgq-dconf-0.36.0-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GIO_EXTRA_MODULES='/nix/store/4fq6w7ksq1dba80sxpdgzrxpd46kdjgq-dconf-0.36.0-lib/lib/gio/modules'${GIO_EXTRA_MODULES:+':'}$GIO_EXTRA_MODULES
export GDK_PIXBUF_MODULE_FILE='/nix/store/d0r5r3zcjipx1qxqxmf1mqzwbay04vq3-librsvg-2.48.2/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'
export XDG_DATA_DIRS='/nix/store/6yrlycwcnxlgg6bkhq4jvwmahyrj00id-gtk+3-3.24.17/share/gsettings-schemas/gtk+3-3.24.17:/nix/store/78x2nyfhhili5ijd6l74z3flj63p92s0-gsettings-desktop-schemas-3.36.0/share/gsettings-schemas/gsettings-desktop-schemas-3.36.0'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS
export XDG_DATA_DIRS='/nix/store/7m99r1fx36zndgxrilg6kppg8k0d6pjb-termite-15/share'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS

Adding gsettings-desktop-schemas to buildInputs has not effect.

I'm still trying to figure out what's the difference between termite and sway's wrapper.

@ghost
Copy link

ghost commented May 5, 2020

I could not manage to make wrapGAppsHook add the missing prefixes to the wrapper. If I add the prefixes manually (like the example from the documentation linked by worldofpeace) it works, but I cannot manage to make wrapGAppsHook add them automatically.

If somebody that has more knowledge than me on this subject can help, that would be great :).

EDIT: Found my issue (I was confused by the behavior of optional vs optionals)

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/some-lose-ends-for-sway-on-nixos-which-we-should-fix/17728/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants