Skip to content

Conversation

@lucasew
Copy link
Contributor

@lucasew lucasew commented Oct 31, 2025

I am looking to experiment with extracting colors and working with them in the oklch color space so I could get more consistent colors and with better contrast. The first step in my vision is to allow this project to let me replace the palette generator logic and this PR has the objective to allow me that.


@stylix-automation stylix-automation bot added the topic: stylix /stylix/ subsystem label Oct 31, 2025
@lucasew lucasew force-pushed the feat/allow-colorscheme-generator-swap branch from cf40aa4 to 5c04fd4 Compare October 31, 2025 19:43
@lucasew lucasew changed the title palette: add option to allow a user to swap the colorscheme generator logic palette: add option to allow swapping colorscheme generator logic Oct 31, 2025
@lucasew
Copy link
Contributor Author

lucasew commented Oct 31, 2025

I am going to rebase from stable so I can test in my current system.

@lucasew lucasew force-pushed the feat/allow-colorscheme-generator-swap branch from 5c04fd4 to bb72bbd Compare October 31, 2025 19:56
@stylix-automation stylix-automation bot added topic: documentation Documentation additions or improvements topic: dependencies Dependency updates topic: nixos NixOS target topic: home-manager Home Manager target topic: darwin nix-darwin target topic: droid Nix-on-Droid target topic: overlay Overlay changes topic: testbed Testbed changes backport: release-25.05 Changes to release-25.05 stable branch topic: ci /.github/ subsystem topic: flake /flake.nix, /flake.lock, and /flake/ subsystems topic: modules /modules/ subsystem labels Oct 31, 2025
@lucasew lucasew changed the base branch from master to release-25.05 October 31, 2025 19:56
@lucasew
Copy link
Contributor Author

lucasew commented Oct 31, 2025

MHAHAHAHAAH it works
image

@lucasew lucasew force-pushed the feat/allow-colorscheme-generator-swap branch from bb72bbd to 4c3bf20 Compare October 31, 2025 20:16
@lucasew lucasew changed the base branch from release-25.05 to master October 31, 2025 20:16
@lucasew
Copy link
Contributor Author

lucasew commented Oct 31, 2025

Basically I copied over the example code using a hardcoded color to my config setup, built my config then in the config generated there is the etc folder where it generates the html with the colorscheme. It changed the colors.

@lucasew lucasew force-pushed the feat/allow-colorscheme-generator-swap branch 3 times, most recently from 902f757 to cc8a714 Compare November 3, 2025 12:39
Copy link
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

I am looking to experiment with extracting colors and working with them in the oklch color space so I could get more consistent colors and with better contrast.

Just out of curiosity, did you make any progress on this, and how does it compare to Matugen from #892?

The first step in my vision is to allow this project to let me replace the palette generator logic and this PR has the objective to allow me that.

Although you might be the first one interested in out-of-tree palette generator customizations, this sounds like a neat future proof addition without much additional complexity. I would not mind adding this if @0xda157 and @danth also approve the idea.

readOnly = true;
internal = true;
default = (lib.importJSON cfg.generated.json) // {
default = validateBase16Palette (lib.importJSON cfg.generated.json) // {
Copy link
Member

Choose a reason for hiding this comment

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

Would this not be better as a check for paletteGeneratorFunction? Otherwise, an assertion would also be fine.

default =
{ polarity, image }:
pkgs.runCommand "palette.json" { } ''
${lib.getExe cfg.paletteGenerator} "${polarity}" ${lib.escapeShellArg image} "$out"
Copy link
Member

Choose a reason for hiding this comment

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

This should be properly wrapped as before:

Suggested change
${lib.getExe cfg.paletteGenerator} "${polarity}" ${lib.escapeShellArg image} "$out"
${lib.getExe cfg.paletteGenerator} \
"${polarity}" \
${lib.escapeShellArg image} \
"$out"

Comment on lines +34 to +37
missingColors = lib.filter (c: !(palette ? ${c})) requiredColors;
in
if missingColors != [ ] then
throw "Palette generator output is missing required base16 colors: ${lib.concatStringsSep ", " missingColors}"
Copy link
Member

@trueNAHO trueNAHO Nov 18, 2025

Choose a reason for hiding this comment

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

Aside from missing outputs, there may also be undesired outputs. Instead of generating a complex diff, it would be better to simply log both with something like:

let
  concatStringsSep = builtins.concatStringsSep ", ";
  expected = [/* ... */];
in
  palette: let
    actual = builtins.attrNames palette;
  in
    lib.throwIf
    (actual != expected)
    "stylix: palette generator output expected ${
      concatStringsSep expected
    }, but got: ${
      concatStringsSep actual
    }"
    palette

'';
type = lib.types.functionTo lib.types.package;
default =
{ polarity, image }:
Copy link
Member

Choose a reason for hiding this comment

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

Consider sorting the arguments:

Suggested change
{ polarity, image }:
{ image, polarity }:

Comment on lines +82 to +109
Example:
```nix
paletteGeneratorFunction = { polarity, image }:
let
color = "ffffff";
colormap = {
base00 = color;
base01 = color;
base02 = color;
base03 = color;
base04 = color;
base05 = color;
base06 = color;
base07 = color;
base08 = color;
base09 = color;
base0A = color;
base0B = color;
base0C = color;
base0D = color;
base0E = color;
base0F = color;
};
in
pkgs.runCommand "palette.json" {color = "ffffff"; } \'\'
echo \'\$\{builtins.toJSON colormap}\' > $out
\'\';
Copy link
Member

Choose a reason for hiding this comment

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

This should be in example. Ideally, it implements a reasonable alternative real-world example.

Comment on lines +79 to +80
- `polarity`: The polarity setting ("either", "light", or "dark")
- `image`: Path to the wallpaper image
Copy link
Member

Choose a reason for hiding this comment

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

Consider sorting the arguments:

Suggested change
- `polarity`: The polarity setting ("either", "light", or "dark")
- `image`: Path to the wallpaper image
- `image`: Path to the wallpaper image
- `polarity`: The polarity setting ("either", "light", or "dark")

@lucasew
Copy link
Contributor Author

lucasew commented Nov 19, 2025

Actually I didn't worked much on this front of work. But the script would basically convert oklch colors to RGB to apply in apps.

@lucasew lucasew force-pushed the feat/allow-colorscheme-generator-swap branch from cc8a714 to be66691 Compare November 19, 2025 15:52
@0xda157
Copy link
Contributor

0xda157 commented Nov 21, 2025

I'd like to merge #892 first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport: release-25.05 Changes to release-25.05 stable branch topic: ci /.github/ subsystem topic: darwin nix-darwin target topic: dependencies Dependency updates topic: documentation Documentation additions or improvements topic: droid Nix-on-Droid target topic: flake /flake.nix, /flake.lock, and /flake/ subsystems topic: home-manager Home Manager target topic: modules /modules/ subsystem topic: nixos NixOS target topic: overlay Overlay changes topic: stylix /stylix/ subsystem topic: testbed Testbed changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants