-
Notifications
You must be signed in to change notification settings - Fork 42
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
tt 0 11 wip #47
base: main
Are you sure you want to change the base?
tt 0 11 wip #47
Conversation
variant = set.variant or null; | ||
|
||
# Colors | ||
palette = set.palette or set.colors or (lib.filterAttrs (n: _: lib.hasPrefix "base" n) set); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep backwards compat with top-level base*
keys
validChars = lib.stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-"; | ||
isValid = x: lib.elem x validChars; | ||
|
||
slugify = str: lib.toLower (filterChars isValid (lib.replaceStrings [" "] ["-"] str)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec instructs us to instead replace all non-ASCII with their ASCII approximations, and only then drop the non alphanum ones.
ASCII approximations is apperently very tricky with pure nix. Lookup tables seems to be the way to go, but it's not an ideal solution performance wise either.
https://github.com/tinted-theming/home/blob/main/builder.md#slugify
type = types.str; | ||
default = ""; | ||
type = types.nullOr types.str; | ||
default = null; | ||
example = "Awesome Scheme"; | ||
description = '' | ||
Color scheme (pretty) name | ||
''; | ||
}; | ||
description = mkOption { | ||
type = types.str; | ||
default = ""; | ||
type = types.nullOr types.str; | ||
default = null; | ||
example = "A very nice theme"; | ||
description = '' | ||
Color scheme author | ||
''; | ||
}; | ||
author = mkOption { | ||
type = types.str; | ||
default = ""; | ||
type = types.nullOr types.str; | ||
default = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably is a breaking change for people defining their schemes in straight nix and that decided to omit name/description/author. People using schemes provided by schemeFromYAML
should not come across null values, though.
I think it's more correct to default to null and let consumers handle what to do with null values instead. I wonder if there's a good way to communicate this change with a warning or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slug has always been required in nix-colors, but maybe I should instead follow the spec more closely and make name
required and slug
optional (inferrable by slugify
).
This might be a breaking change, unless:
- Do some conditionals to default
name
toslug
if it's non-null; and/or - Set a fallback generic name with a warning
As mentioned in #44 (comment):
|
#44