diff --git a/README.md b/README.md index d946254a..be772931 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,18 @@ use: `base16Scheme` can also accept other formats as supported by [`mkSchemeAttrs`](https://github.com/SenchoPens/base16.nix/blob/main/DOCUMENTATION.md#mkschemeattrs). +## Overriding + +For convenience, it is possible to override parts of `stylix.base16Scheme` using +`stylix.override`. Anything that +[base16.nix](https://github.com/SenchoPens/base16.nix) accepts as override is +valid. + +When using both the Home Manager and NixOS modules, both the system overrides +and the user-provided one are used in the user configuration if +`stylix.base16Scheme` is not changed in the user config. If that is the case, +only the user override is used. + ## Fonts The default combination of fonts is: diff --git a/stylix/palette.nix b/stylix/palette.nix index 08ad885e..9cd04037 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -19,6 +19,12 @@ let slug = "stylix"; }; + override = + (if cfg.base16Scheme == fromOs [ "base16Scheme" ] {} + then fromOs [ "override" ] {} + else {}) + // cfg.override; + in { # TODO link to doc on how to do instead imports = [ @@ -100,11 +106,23 @@ in { but could be overridden manually. ''; }; + + override = mkOption { + description = '' + An override that will be applied to stylix.base16Scheme when generating + lib.stylix.colors. + + Takes anything that a scheme generated by base16nix can take as argument + to override. + ''; + type = types.attrs; + default = {}; + }; }; config = { # This attrset can be used like a function too, see # https://github.com/SenchoPens/base16.nix#mktheme - lib.stylix.colors = base16.mkSchemeAttrs cfg.base16Scheme; + lib.stylix.colors = (base16.mkSchemeAttrs cfg.base16Scheme).override override; }; }