nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.14k stars 1.84k forks source link

bug: Impossible to disable theming for GTK4 #5133

Open Quadrubo opened 8 months ago

Quadrubo commented 8 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

The commit https://github.com/nix-community/home-manager/commit/e9b9ecef4295a835ab073814f100498716b05a96#diff-7d7e3718822ace30b2dc9dd86ef97329bfc89c9262ccad07f5777d0ff3cc8924 introduced a bug for me, as I was using adw-gtk3 to theme legacy applications.

I don't want to theme gtk4 applications with that theme. The manpage for nix also states that gtk.enable enables theming for gtk2/3. gtk.theme says the gtk2/3 theme to use.

I don't think setting the theme using this option should automatically apply to all gtk versions. Please note that I'm new to nixos so if one could inform me of any way to overwrite the gtk4Css variable this would work for me.

However I think a better approach would be to let the user choose themes for each different gtk version. Something like this:

gtk = {
    enable = true;

    gtk3 = {
      enable = true;
      theme = {
        package = pkgs.adw-gtk3;
        name = "adw-gtk3";
      };
    };

    gtk4 = {
      enable = false;
    };
  };

Maintainer CC

@rycee

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.6.21, NixOS, 24.05 (Uakari), 24.05.20240309.3030f18`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/store/nra828scc8qs92b9pxra5csqzffb6hpl-source`
howyay commented 8 months ago

A workaround is to use home.activation to delete ~/.config/gtk-4.0/gtk.css for now:

home.activation.removeGTK4Theming = lib.hm.dag.entryAfter ["writeBoundary"] ''rm ${config.xdg.configHome}/gtk-4.0/gtk.css'';

Quadrubo commented 8 months ago

A workaround is to use home.activation to delete ~/.config/gtk-4.0/gtk.css for now:

home.activation.removeGTK4Theming = lib.hm.dag.entryAfter ["writeBoundary"] ''rm ${config.xdg.configHome}/gtk-4.0/gtk.css'';

Thank you for the workaround. This is working for now.

MOIS3Y commented 8 months ago

@howyay hi!

This also breaks the work of gtk4.extraCss

2024-03-26-18-28-20

2024-03-26-18-30-49

Is there a way to override gtk4Css so that it doesn't import from the theme? So far I only see the opportunity to copy the module into the configuration and change its behavior. This is clearly not right

This workaround won't work (

  home.activation.removeGTK4Theming = lib.hm.dag.entryAfter ["writeBoundary"] ''rm ${config.xdg.configHome}/gtk-4.0/gtk.css'';
  home.file."${config.xdg.configHome}/gtk-4.0/gtk.css".text = ''${extraCss}'';
howyay commented 8 months ago

@howyay hi!

This also breaks the work of gtk4.extraCss

2024-03-26-18-28-20

2024-03-26-18-30-49

Is there a way to override gtk4Css so that it doesn't import from the theme? So far I only see the opportunity to copy the module into the configuration and change its behavior. This is clearly not right

This workaround won't work (

  home.activation.removeGTK4Theming = lib.hm.dag.entryAfter ["writeBoundary"] ''rm ${config.xdg.configHome}/gtk-4.0/gtk.css'';
  home.file."${config.xdg.configHome}/gtk-4.0/gtk.css".text = ''${extraCss}'';

I trust that you probably already figured this out - but its worth noting that there is no need to delete it in the first place if you just wish to overwrite it. Using output redirection > should discard any existing content and overwrite with your desired content.

KaiserCalm commented 5 months ago

I was about to write a new bug report. I am pretty sure that line 291 of this commit is completely broken and forces home manager to always create the gtk4.css file, because the string on line 238 is never going to be empty.

I propose to change 291 from:

xdg.configFile."gtk-4.0/gtk.css" = mkIf (gtk4Css != "") { text = gtk4Css; };

To this:

xdg.configFile."gtk-4.0/gtk.css" = mkIf (cfg4.extraCss != "") { text = gtk4Css; };

It would work the same way the gtk3.css option currently works.

panurg commented 4 months ago

I have exactly the same configuration as author and run into the same problem. I think it is quite severe, because dark mode in Gnome is completely broken in libadwaita apps for me.

stale[bot] commented 3 weeks ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

KaiserCalm commented 3 weeks ago

Not stale. I am completely unable to use the options for GTK as this issue makes the module settings completely broken.