Skip to content

Commit

Permalink
stylix: add missing 'config.stylix.enable' guards
Browse files Browse the repository at this point in the history
Aside from the 'stylix/nixos/default.nix' and 'stylix/target.nix' files,
I tried to keep the diffs small.
  • Loading branch information
trueNAHO committed May 5, 2024
1 parent 46dda51 commit c1a090f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion stylix/fonts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ in {
};
};

config = {
config = lib.mkIf config.stylix.enable {
stylix.fonts.packages = [
cfg.monospace.package
cfg.serif.package
Expand Down
7 changes: 4 additions & 3 deletions stylix/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ in {
};
};

config = lib.optionalAttrs (options ? home-manager) (lib.mkIf (hm.autoImport && config.stylix.enable) {
home-manager.sharedModules = [ homeManagerModule ];
});
config.home-manager.sharedModules =
lib.mkIf
(config.stylix.enable && options ? home-manager && hm.autoImport)
[ homeManagerModule ];
}
2 changes: 1 addition & 1 deletion stylix/palette.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ in {
};
};

config = {
config = lib.mkIf config.stylix.enable {
# This attrset can be used like a function too, see
# https://github.com/SenchoPens/base16.nix/blob/b390e87cd404e65ab4d786666351f1292e89162a/README.md#theme-step-22
lib.stylix.colors = (base16.mkSchemeAttrs cfg.base16Scheme).override override;
Expand Down
16 changes: 11 additions & 5 deletions stylix/target.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ with lib;
let
fromOs = import ./fromos.nix { inherit lib args; };
in {
options.stylix.enable = lib.mkEnableOption "stylix";
options.stylix.autoEnable = mkOption {
description = "Whether to automatically enable styling for installed targets.";
type = types.bool;
default = fromOs [ "autoEnable" ] true;
options.stylix = {
autoEnable = mkOption {
default = fromOs [ "autoEnable" ] config.stylix.enable;

description =
"Whether to automatically enable styling for installed targets.";

type = types.bool;
};

enable = lib.mkEnableOption "stylix";
};

config.lib.stylix.mkEnableTarget =
Expand Down

0 comments on commit c1a090f

Please sign in to comment.