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

nixos/gtk: init #80865

Closed
wants to merge 1 commit into from
Closed

nixos/gtk: init #80865

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 23, 2020

Motivation for this change

See #71079
Qt part #80866

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Comment on lines +72 to +73
gtk = {
enable = mkEnableOption "Gtk theming configuration";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the namespace here when there's gtk.iconCache.

I feel like this module is all about https://developer.gnome.org/gtk3/stable/GtkSettings.html.
So I think we should do:

  • nixos/modules/config/gtk/settings.nix
  • gtk.settings.enable gtk.settings.theme = {...

cc @jtojnar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about gtk.iconCache: I agree it conflicts with this modules but calling it gtk.settings make it looks like a NixOS/rfcs#42 type of option, which is not

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worldofpeace @rnhmjoj So how should we call it?

themeType = types.submodule {
options = {
package = mkOption {
internal = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this internal? Shouldn't it have an example and a description, instead of the literalExample below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worldofpeace Package is used in a bunch of options, and is different dependening on the option. I don't see how we get rid of literalExamples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be internal because of this though. Also why is nullOr necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@infinisil the package for option may be already provided in other place, for e.g. in qt module or it maybe a common font. There is no reason to force user set package for every option here.

Comment on lines +121 to +132
theme = mkOption {
type = types.nullOr themeType;
default = null;
example = literalExample ''
{
name = "Adwaita";
package = pkgs.gnome-themes-extra;
};
'';
description = "The GTK+ theme to use.";
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the most popular properties were added here for gtk settings, which is good.
But I believe this module should allow us to set any of the other properties in GtkSettings, rfc 42 style NixOS/rfcs#42.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to get back to you in a bit on an implementation suggestion.

Comment on lines +137 to +142
(mkIf gtk2 {
environment.etc."xdg/gtk-2.0/gtkrc".text =
concatStringsSep "\n" (
mapAttrsToList toGtk2File settings
);
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhhn, this might be problematic if we allow to set any other properties. Because any other gtk.settings.* will likely be for gtk3, and they don't have all the same properties.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worldofpeace What should we do?

@jtojnar
Copy link
Contributor

jtojnar commented Feb 24, 2020

One thing this is lacking is a test suite. Ideally a Matrix of gnome, gnome-xorg, i3 or something and sway.

@ghost
Copy link
Author

ghost commented Mar 3, 2020

@jtojnar

One thing this is lacking is a test suite. Ideally a Matrix of gnome, gnome-xorg, i3 or something and sway

What test should do? Just take screenshots? What gtk program should be used to demonstrate that settings do work? Sway will show nothing until there is a solution for #54150

@jtojnar
Copy link
Contributor

jtojnar commented Mar 4, 2020

I think having a simple script verifying that the setting apply in different environments (i3, Sway, Plasma, GNOME Shell) should be good.

Something like

machine.succeed("fc-match serif | grep '\"Gentium Plus\"'")
machine.succeed("fc-match sans-serif | grep '\"Cantarell\"'")
machine.succeed("fc-match monospace | grep '\"Source Code Pro\"'")
machine.succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'")

Looking at https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Settings.html#Gtk.Settings.props.gtk_theme_name, I would expect something like this to work but it does not seem to:

nix-shell -p gobject-introspection -p gtk3 -p 'python3.withPackages (p: with p; [pygobject3])' --run "python3 -c \"import gi; gi.require_version('Gtk', '3.0'); from gi.repository import Gtk; s = Gtk.Settings.get_default(); print(s.props.gtk_theme_name)\""

@ghost ghost requested review from worldofpeace and rnhmjoj May 11, 2020 09:01
@ghost ghost closed this Jul 3, 2020
@ghost ghost deleted the gtk-theming branch July 3, 2020 19:02
@Henry-Hiles
Copy link
Contributor

I might try to pick this up and make a new pr could be useful. If anyone has any concerns to raise about a new pr lmk.

@jtojnar
Copy link
Contributor

jtojnar commented Jan 27, 2024

If we want this, we will probably want to not treat all GTK versions as monoliths and go more in the direction of RFC 42.

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

Successfully merging this pull request may close these issues.

None yet

5 participants