Skip to content

Awesome 4.3: beautiful.gtk is not supported #60538

@stefano-m

Description

@stefano-m

Cc: @dtzWill

Issue description

First of all, thanks to everyone for working on NixOS.

Awesome 4.3 has a module called beautiful.gtk, it allows

Querying current GTK+ 3 theme via GtkStyleContext.

It can be used for theming, as shown in Awesome's example gtk theme.

However, the current build does not include the typelib files needed by the module making it unusable.

Investigation

The beautiful.gtk implementation uses lgi to obtain Gtk via gobject-introspec

    return require('lgi').Gtk

Since the current build does not include the typelib files needed, the above call fails.

After some experimentation, I found out that both gtk3-x11 and atk are needed.

For example:

  1. run lua and try to load Gtk: fails with Typelib file for namespace 'Gtk' (any version) not found
$ lua
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> Gtk = require('lgi').Gtk
...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:158: Typelib file for namespace 'Gtk' (any version) not found
stack traceback:
        [C]: in function 'assert'
        ...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:158: in function <...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:155>
        (...tail calls...)
        stdin:1: in main chunk
        [C]: in ?
>
  1. install gtk3-x11 (the package that actually includes the typelib file) and add the girepository-1.0 folder to the GI_TYPELIB_PATH environment variable: fails with Typelib file for namespace 'Atk', version '1.0' not found
$ nix-env -iA nixpkgs.gtk3-x11
$ export GI_TYPELIB_PATH=/nix/store/nav1j5p1ac814y47ngiapwzdk75hzly5-gtk+3-3.24.5/lib/girepository-1.0:$GI_TYPELIB_PATH
$ lua
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
>
> g = require('lgi').Gtk
...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:158: Typelib file for namespace 'Atk', version '1.0' not found
stack traceback:
        [C]: in function 'assert'
        ...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:158: in function <...26fkq-lua5.2-lgi-0.9.2-1/share/lua/5.2/lgi/namespace.lua:155>
        (...tail calls...)
        stdin:1: in main chunk
        [C]: in ?
>
  1. install atk and add it to GI_TYPELIB_PATH and finally Gtk loads.

Steps to reproduce

  1. start Awesome as window manager
  2. modify ~/.config/awesome/rc.lua to load the example gtk theme
beautiful.init(
  gears.filesystem.get_themes_dir() .. "gtk/theme.lua"
)
  1. restart awesome
  2. observe the warnings issues by Awesome:
$ journalctl --user --since=today | grep 'GTK'
xsession[28002]: W: awesome: Can't load GTK+3 introspection. Seems like GTK+3 is not installed or `lua-lgi` was built with an incompatible GTK+3 version.
xsession[28002]: W: awesome: Can't load GTK+3 theme. Using 'xresources' theme as a fallback.

Possible solution

I suggest that both atk and gtk-x11 are added as build inputs to the awesome package, I tried this out and it actually works. The catch is that the closure size increases by 123.9M:

  • build awesome without gtk3-x11 and atk
    nix path-info ./result | grep awesome-> 99.6M

  • build awesome with gtk3-x11 and atk
    nix path-info ./result | grep awesome -> 223.4M

So, instead of adding the packages unconditionally, we could add an optional flag, like e.g. withGtkSupport, defaulting to false. In this way, one could always build awesome and add it to services.xserver.windowManager.awesome.package. Ideally one could even add something like awesome-gtk3 to the top level nixpkgs, a bit like gtk3-x11:

gtk3-x11 = gtk3.override {
x11Support = true;
};

If a decision is made, I'd be happy to submit a PR.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.19.36-hardened, NixOS, 19.03.172361.cf3e277dd0b (Koi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(root): "nixos-19.03.172361.cf3e277dd0b"
  • channels(user): "unstable-19.09pre177249.dfd8f84aef1"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

awesome 4.3 (Too long)

  • Compiled against Lua 5.2.4 (running with Lua 5.2)
  • D-Bus support: ✔
  • execinfo support: ✔
  • xcb-randr version: 1.6
  • LGI version: 0.9.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions