diff --git a/docs/src/modules.md b/docs/src/modules.md index ab80668a8..98365e2e8 100644 --- a/docs/src/modules.md +++ b/docs/src/modules.md @@ -58,6 +58,13 @@ A general format for modules is shown below. } ``` +> [!CAUTION] +> You **must** check _both_ `config.stylix.enable` _and_ your target's own +> `enable` option before defining any config. +> +> In the above example this is done using +> `config = lib.mkIf (config.stylix.enable && config.stylix.targets.«name».enable)`. + The human readable name will be inserted into the following sentence: > Whether to enable theming for «human readable name». diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix index 48774d541..dfb63c1a0 100644 --- a/modules/gtk/hm.nix +++ b/modules/gtk/hm.nix @@ -38,7 +38,7 @@ in flatpakSupport.enable = config.lib.stylix.mkEnableTarget "support for theming Flatpak apps" true; }; - config = lib.mkIf cfg.enable ( + config = lib.mkIf (config.stylix.enable && cfg.enable) ( lib.mkMerge [ { warnings = diff --git a/modules/kitty/hm.nix b/modules/kitty/hm.nix index 72594ae55..2c2ed99b1 100644 --- a/modules/kitty/hm.nix +++ b/modules/kitty/hm.nix @@ -21,7 +21,7 @@ in }; }; - config = lib.mkIf cfg.enable { + config = lib.mkIf (config.stylix.enable && cfg.enable) { programs.kitty = { font = { inherit (config.stylix.fonts.monospace) package name; diff --git a/modules/kubecolor/hm.nix b/modules/kubecolor/hm.nix index 8a3061306..64d878fa5 100644 --- a/modules/kubecolor/hm.nix +++ b/modules/kubecolor/hm.nix @@ -1,9 +1,12 @@ { config, lib, ... }: +let + cfg = config.stylix.targets.kubecolor; +in { options.stylix.targets.kubecolor.enable = config.lib.stylix.mkEnableTarget "kubecolor" true; - config = lib.mkIf config.stylix.targets.kubecolor.enable { + config = lib.mkIf (config.stylix.enable && cfg.enable) { programs.kubecolor.settings = { preset = if config.stylix.polarity == "either" then "" else "${config.stylix.polarity}"; diff --git a/stylix/target.nix b/stylix/target.nix index 12b8494b3..1074acb3d 100644 --- a/stylix/target.nix +++ b/stylix/target.nix @@ -40,7 +40,7 @@ humanName: autoEnable: lib.mkEnableOption "theming for ${humanName}" // { - default = cfg.enable && cfg.autoEnable && autoEnable; + default = cfg.autoEnable && autoEnable; example = !autoEnable; } // lib.optionalAttrs autoEnable {