diff --git a/modules/home/stylix/default.nix b/modules/home/stylix/default.nix index 04c26a8..9d79091 100644 --- a/modules/home/stylix/default.nix +++ b/modules/home/stylix/default.nix @@ -17,7 +17,6 @@ let "moonfly" "nord" "oxocarbon" - "generate-from-image" ]; # schemes names in `pkgs.base16-schemes` that need a suffix needsSuffix = [ @@ -31,6 +30,11 @@ let ]; schemeName = if builtins.elem cfg.scheme needsSuffix then "${cfg.scheme}-${cfg.polarity}" else cfg.scheme; + scheme = + if builtins.elem cfg.scheme customSchemes then + ./schemes/${schemeName}.yaml + else + "${pkgs.base16-schemes}/share/themes/${schemeName}.yaml"; inherit (lib) mkDefault @@ -47,13 +51,13 @@ in options.stylix = { scheme = lib.mkOption { - type = types.str; + type = types.nullOr types.str; default = "dracula"; description = '' Base16 color scheme name. Available options are: ${toString validSchemes} - "generate-from-image" generates a color scheme from `stylix.image` + Set to `null` to generate a color scheme from `stylix.image` ''; }; }; @@ -64,16 +68,15 @@ in assertion = builtins.elem cfg.scheme validSchemes; message = "Stylix: Invalid colorscheme '${cfg.scheme}'. Available options: ${toString validSchemes}"; } + { + assertion = (cfg.scheme != null) || (cfg.image != null); + message = "Stylix: You need to set stylix.image if stylix.scheme is `null`"; + } ]; stylix = { autoEnable = mkDefault true; - base16Scheme = mkIf (cfg.scheme != "generate-from-image") ( - if builtins.elem cfg.scheme customSchemes then - ./schemes/${schemeName}.yaml - else - "${pkgs.base16-schemes}/share/themes/${schemeName}.yaml" - ); + base16Scheme = mkIf (cfg.scheme != null) scheme; fonts = { monospace = mkDefault { package = pkgs.hack-font; diff --git a/modules/home/stylix/targets/nixvim.nix b/modules/home/stylix/targets/nixvim.nix index b6dbec4..7fcdd33 100644 --- a/modules/home/stylix/targets/nixvim.nix +++ b/modules/home/stylix/targets/nixvim.nix @@ -4,13 +4,11 @@ let cfg = config.stylix; target = cfg.targets.nixvim; - inherit (lib) mkIf optionalAttrs; + inherit (lib) mkIf; in { config = mkIf cfg.enable { stylix.targets.nixvim.enable = false; - programs.nixvim.colorschemes = optionalAttrs (cfg.scheme != "generate-from-image") { - "${cfg.scheme}".enable = !target.enable; - }; + programs.nixvim.colorschemes."${cfg.scheme}".enable = !target.enable; }; } diff --git a/tests/build/hm-hyprland/default.nix b/tests/build/hm-hyprland/default.nix index 083c68f..9b034fa 100644 --- a/tests/build/hm-hyprland/default.nix +++ b/tests/build/hm-hyprland/default.nix @@ -23,8 +23,6 @@ }; stylix.enable = true; - stylix.scheme = "generate-from-image"; - stylix.image = ./wallpaper.png; home.stateVersion = "25.11"; } diff --git a/tests/build/hm-hyprland/wallpaper.png b/tests/build/hm-hyprland/wallpaper.png deleted file mode 100644 index a9edb68..0000000 Binary files a/tests/build/hm-hyprland/wallpaper.png and /dev/null differ