Core styling module + alacritty example - #184
Open
kmein wants to merge 3 commits into
Open
Conversation
Wrapper modules are evaluated independently of each other, so there is no shared configuration a theme can live in. Every theme-adjacent option today is program-local pass-through: rofi takes rasi, yazi and helix take TOML, waybar and swaync take raw CSS, and the four terminals take colour keys in four different formats. Sharing one palette means writing the same hex strings into a dozen incompatible files by hand. Add a styling module, in the spirit of stylix, imported into every wrapper alongside wrapper and meta. It holds one colour scheme, font, opacity and cursor definition that programs derive their own configuration from, and wlib.applyStyle maps a single definition over as many modules as wanted. styling.scheme takes a base16 scheme by name from pkgs.base16-schemes, by path or derivation, or inline. It seeds styling.palette, which stays settable per slot so a scheme is a starting point rather than a cage. styling.colors exposes the palette under semantic names plus the standard base16 mapping onto the 16 ANSI colours, so terminals do not each have to invent their own. Scheme loading is a small line based parser rather than a YAML tool: that keeps it pure, which matters because CI is nix flake check. The parser is tested against all 303 schemes nixpkgs ships. styling.enable turns on as soon as a scheme is set, so one definition themes everything, and can be switched off per wrapper. With no scheme configured it is false and no existing wrapper changes behaviour. The namespace is styling rather than style because swayosd already declares a style option, and theme and themes are taken by rofi, yazi, helix and jjui. An always-imported module cannot collide with any of them. No program module consumes this yet. The README documents the pattern they will follow, and checks/styling-enable.nix pins the priority contract it rests on: derived values must be defaults, or a settings definition at priority 100 silently outranks the user's own value. Assisted-by: Claude Opus 5
Add a styling.nix deriving colours, font and opacity from the styling module, as the worked example the README points at, and a check.nix, which alacritty did not have before. The check asserts on the generated config rather than the built wrapper, so it does not build alacritty. Assisted-by: Claude Opus 5
Collaborator
|
implements #22 |
The parser carried a lowercasing table and an older flat layout branch that nothing in pkgs.base16-schemes uses: all 303 schemes there write the canonical `base0A` under a `palette:` block. Parse that shape only; a file spelling a slot otherwise is reported as missing it. Drop the attrset form of `styling.scheme`. It was redundant with `styling.palette.<slot>`, which outranks the scheme anyway, and with it go normalizePalette, normalizeColor and bySlug. Also drop the unread `name` from a parsed scheme; `variant` stays, since polarity reads it. Define `styling.colors` as one read only option computed from the palette rather than 37 individual alias options. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspired by the great stylix I wanted to explore how wrappers could be used to achieve a similar thing.
This PR adds a core module
styling(supporting base16 colour schemes, fonts, opacity and cursor settings) and an example styling implementation for alacritty.