danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.23k stars 158 forks source link

Overriding Gnome template #621

Open musjj opened 2 weeks ago

musjj commented 2 weeks ago

I wanted to override a few colors for Gnome (without recreating all the needed derivations), but it looks like that the template is hardcoded.

There's this relevant thread: https://github.com/danth/stylix/issues/159 about moving these templates out-of-tree. Would a PR for separating the mustache template to a different repo be acceptable here?

trueNAHO commented 1 week ago

I wanted to override a few colors for Gnome (without recreating all the needed derivations), but it looks like that the template is hardcoded.

Ideally, we would upstream (NixOS, Home Manager, or nix-darwin) relevant options to seamlessly integrate Stylix into external Nix code.

There's this relevant thread: #159 about moving these templates out-of-tree. Would a PR for separating the mustache template to a different repo be acceptable here?

The future Vim highlight groups would allow us to get rid of mustache templates:

the roadmap eventually causes Stylix to implement all templates without relying on external dependencies

-- https://github.com/danth/stylix/issues/567#issuecomment-2403246345

musjj commented 1 week ago

Are the patches really suitable for upstreaming though? It contains a lot of stylix-specific changes, like removing dark mode. The style sheet itself is also fairly opinionated and custom, which is not something I usually see upstream.

trueNAHO commented 1 week ago

Are the patches really suitable for upstreaming though? It contains a lot of stylix-specific changes, like removing dark mode. The style sheet itself is also fairly opinionated and custom, which is not something I usually see upstream.

My idea was to move our string injection architecture

xdg.configFile."<MODULE>".text = "<KEY>=<VALUE>";

upstream, and then we only use its interface:

programs.<MODLE>.extraConfig."<KEY>" = "<VALUE>";

This centralizes the string injection upstream and hopefully gets rid of override issues:

the use of extraConfig might cause other potentially related issues. As discussed in #159 (comment), it makes it harder to override options, and as discussed in #388 (comment), it makes it easier to accidentally override Stylix options.

-- https://github.com/danth/stylix/issues/395

musjj commented 1 week ago

I see, but in the case for Gnome you can't feed the values via xdg.configFile though. The Gnome module involves a lot of patching, so upstreaming them all to NixOS + home-manager seems unlikely IMO.

I think a more sensible short-term approach is to import the template files via the inputs in flake.nix (using url = "path:./templates/..." so you don't have to make a bunch of repositories). This will allow the user to override it. The downside is that you can't override it partially. What do you think?

trueNAHO commented 1 week ago

I see, but in the case for Gnome you can't feed the values via xdg.configFile though. The Gnome module involves a lot of patching, so upstreaming them all to NixOS + home-manager seems unlikely IMO.

Yes.

I think a more sensible short-term approach is to import the template files via the inputs in flake.nix (using url = "path:./templates/..." so you don't have to make a bunch of repositories). This will allow the user to override it. The downside is that you can't override it partially. What do you think?

This sounds like a really good short-term solution. Feel free to submit a PR.

trueNAHO commented 1 week ago

I think a more sensible short-term approach is to import the template files via the inputs in flake.nix (using url = "path:./templates/..." so you don't have to make a bunch of repositories). This will allow the user to override it. The downside is that you can't override it partially. What do you think?

This sounds like a really good short-term solution. Feel free to submit a PR.

Actually, would it not be better to do this with an option, like stylix.targets.gnome.theme?

musjj commented 1 week ago

Yeah, a stylix.targets.gnome.theme option might be better here if that's allowed. I'm starting to think that overriding templates might not be as useful in Gnome 47 due to: https://github.com/danth/stylix/issues/618, which may require search-replace patching over the css files.