Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions stylix/mk-target.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
{ extension.enable = lib.mkEnableOption "the bloated dependency"; }
```

`configElements` (List or attribute set or function)
`configElements` (List or attribute set or function or path)
: Configuration functions that are automatically safeguarded when any of
their arguments is disabled. The provided `cfg` argument conveniently
aliases to `config.stylix.targets.${name}`.
Expand Down Expand Up @@ -130,7 +130,7 @@
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 or path)
Comment thread
trueNAHO marked this conversation as resolved.
: This argument mirrors the `configElements` argument but intentionally
lacks automatic safeguarding and should only be used for complex
configurations where `configElements` is unsuitable.
Expand Down Expand Up @@ -225,7 +225,7 @@ let
mkConfig = fn: fn (getStylixAttrs fn);

# Safeguard configuration functions when any of their arguments is
# disabled, while non-function configurations are unguarded.
# disabled.
mkConditionalConfig =
c:
if builtins.isFunction c then
Expand Down Expand Up @@ -260,8 +260,14 @@ let

config = lib.mkIf (config.stylix.enable && cfg.enable) (
lib.mkMerge (
lib.optional (generalConfig != null) (mkConfig generalConfig)
++ map mkConditionalConfig (lib.toList configElements)
lib.optional (generalConfig != null) (
mkConfig (
if builtins.isPath generalConfig then import generalConfig else generalConfig
)
)
++ map (c: mkConditionalConfig (if builtins.isPath c then import c else c)) (
lib.toList configElements
)
)
);
};
Expand Down