stylix: allow underscore in mkTarget configElements args (#1473)
Link: https://github.com/nix-community/stylix/pull/1473 Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
commit
c117edd7ee
2 changed files with 21 additions and 5 deletions
|
|
@ -11,7 +11,11 @@
|
||||||
check.enable = true;
|
check.enable = true;
|
||||||
|
|
||||||
settings.hooks = {
|
settings.hooks = {
|
||||||
deadnix.enable = true;
|
deadnix = {
|
||||||
|
enable = true;
|
||||||
|
settings.noUnderscore = true;
|
||||||
|
};
|
||||||
|
|
||||||
editorconfig-checker.enable = true;
|
editorconfig-checker.enable = true;
|
||||||
hlint.enable = true;
|
hlint.enable = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,11 @@
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Arguments prefixed with an underscore (`_`) resolve to their non-prefixed
|
||||||
|
counterparts. For example, the `_colors` argument resolves to `colors`.
|
||||||
|
Underscored arguments are considered unused and should never be accessed.
|
||||||
|
Their sole purpose is satisfying `deadnix` in complex configurations.
|
||||||
|
|
||||||
`generalConfig` (Attribute set or function)
|
`generalConfig` (Attribute set or function)
|
||||||
: This argument mirrors the `configElements` argument but intentionally
|
: This argument mirrors the `configElements` argument but intentionally
|
||||||
lacks automatic safeguarding and should only be used for complex
|
lacks automatic safeguarding and should only be used for complex
|
||||||
|
|
@ -200,17 +205,24 @@ let
|
||||||
fn:
|
fn:
|
||||||
lib.genAttrs (functionArgNames fn) (
|
lib.genAttrs (functionArgNames fn) (
|
||||||
arg:
|
arg:
|
||||||
if arg == "cfg" then
|
let
|
||||||
|
trimmedArg =
|
||||||
|
let
|
||||||
|
prefix = "_";
|
||||||
|
in
|
||||||
|
if lib.hasPrefix prefix arg then lib.removePrefix prefix arg else arg;
|
||||||
|
in
|
||||||
|
if trimmedArg == "cfg" then
|
||||||
cfg
|
cfg
|
||||||
else if arg == "colors" then
|
else if trimmedArg == "colors" then
|
||||||
config.lib.stylix.colors
|
config.lib.stylix.colors
|
||||||
else
|
else
|
||||||
config.stylix.${arg}
|
config.stylix.${trimmedArg}
|
||||||
or (throw "stylix: mkTarget expected one of `cfg`, `colors`, ${
|
or (throw "stylix: mkTarget expected one of `cfg`, `colors`, ${
|
||||||
lib.concatMapStringsSep ", " (name: "`${name}`") (
|
lib.concatMapStringsSep ", " (name: "`${name}`") (
|
||||||
builtins.attrNames config.stylix
|
builtins.attrNames config.stylix
|
||||||
)
|
)
|
||||||
}, but got: ${arg}")
|
}, but got: ${trimmedArg}")
|
||||||
);
|
);
|
||||||
|
|
||||||
# Call the configuration function with its required Stylix arguments.
|
# Call the configuration function with its required Stylix arguments.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue