diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index a3cbdc61..378dfb16 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -23,7 +23,10 @@ in { Doesn't do anything if the home-manager configuration is not used from NixOS. ''; - default = false; + default = + if from-nixos + then mod-args.osConfig.stylix.homeManagerIntegration.enable + else false; }; }; diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 3d5d5756..b80d7500 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -1,8 +1,8 @@ { palette-generator, base16, homeManagerModule }: -{ config, lib, ... }: +{ options, config, lib, ... }: let - cfg = config.stylix.home-manager; + hm = config.stylix.homeManagerIntegration; autoload = import ../autoload.nix { inherit lib; } "nixos"; in { imports = [ @@ -12,15 +12,33 @@ in { (import ./palette.nix { inherit palette-generator base16; }) ] ++ autoload; - options.stylix.home-manager = { - enable = lib.mkEnableOption "home-manager support"; - useSystemTheme = lib.mkEnableOption "system theme in home-manager"; + options.stylix.homeManagerIntegration = { + enable = lib.mkOption { + description = '' + Enable home-manager integration + + This means that by default all the users will use the system + theme, and the stylix hm module will be included in all users + configurations. + ''; + type = lib.types.bool; + default = options ? home-manager; + defaultText = "true if home-manager is imported"; + }; + + disableImport = lib.mkOption { + description = '' + When the home-manager integration is enabled, do not automatically + imports stylix into the user configuration. + ''; + type = lib.types.bool; + default = false; + }; }; - config = lib.mkIf cfg.enable { + config = lib.mkIf (hm.enable && !hm.disableImport) { home-manager.sharedModules = [ homeManagerModule - { stylix.useSystemTheme = lib.mkOverride 99 cfg.useSystemTheme; } ]; }; }