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

stylix: replacing the builtin color scheme generation engine with matugen #892

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

make-42
Copy link
Contributor

@make-42 make-42 commented Feb 23, 2025

This PR is meant to further the discussion in (#694).

I believe matugen could be a good candidate for replacing the builtin color scheme generation engine stylix currently uses and this PR serves as a demo for it.

The code is not final:

  • the old engine is still in the codebase
  • polarity doesn't work like it's supposed to (it selects the color scheme and "either" defaults to black)
  • a lightnessScale parameter could also be implemented as in: stylix: add darker and even-darker polarities #694
  • the choice of colors used in the dark and light themes might need to be changed.

However this is what it looks like:
image

@make-42
Copy link
Contributor Author

make-42 commented Feb 23, 2025

primaryScale parameters have been implemented

@make-42
Copy link
Contributor Author

make-42 commented Feb 23, 2025

primaryScale.dark = -0.05; gives you:
image

and primaryScale.dark = -0.1; gives you:
image

Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

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

This is definitely an improvement over the current generator, at least when I tried it on my own wallpaper :)

As this is still a WIP I've just left a couple of comments.

@@ -78,24 +159,77 @@ in
# and not anything indirect such as filling a template, otherwise
# the output of the palette generator will not be protected from
# garbage collection.
Copy link
Owner

Choose a reason for hiding this comment

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

To keep the garbage collection stuff working, stylix.generated.json should just be the raw-palette.json derivation without any further processing. The importing, processing, etc should be under stylix.generated.palette, and there's no need to write the processed theme back to a file.

options.stylix = {
scheme = lib.mkOption {
Copy link
Owner

Choose a reason for hiding this comment

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

Consider grouping all the new options into a subcategory, to make it clear that they're only for generated themes.

Perhaps also move the polarity option into that category (unless you're planning to remove it).

polarity = lib.mkOption {
type = lib.types.enum [
"either"
Copy link
Owner

Choose a reason for hiding this comment

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

Consider using one of lib.types.coercedTo, lib.mkChangedOptionModule, lib.mkRemovedOptionModule, etc to handle changes to the polarity option.

@make-42
Copy link
Contributor Author

make-42 commented Feb 24, 2025

Okay, I'll work on cleaning this up, do I remove the code for the old palette-generator or do I make an option to have it be selectable for legacy purposes?

@make-42
Copy link
Contributor Author

make-42 commented Feb 24, 2025

I fixed all of the issues that you brought up.

@make-42
Copy link
Contributor Author

make-42 commented Feb 24, 2025

Do you want me to create a gallery of different color scheme options?

@make-42
Copy link
Contributor Author

make-42 commented Feb 24, 2025

although for some reason, i can't get the removed option warning to show up

@make-42
Copy link
Contributor Author

make-42 commented Feb 24, 2025

that was an easy fix...

@Flameopathic
Copy link
Contributor

very cool! will this be able to extend to generating a base24 or vim highlight group scheme?

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

Successfully merging this pull request may close these issues.

4 participants