danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
904 stars 105 forks source link

targets.kitty.enable=false doesn't work #395

Closed Ladas552 closed 1 month ago

Ladas552 commented 1 month ago

Hi.

Issue:

Stylix seems to ignore the targets for kitty, as described in the manual.

Workarounds and poking around:

The only way to disable bugged behavior, applying to kitty, is only with disabling autoEnable option.

On the other hand, Stylix honors the targets options after disabling autoEnable option, for some reason.

Also, it seems Stylix doesn't make a ~/.config/kitty.conf file or edit it.

Info and config

Using Stylix as a Home Manager module on Standalone Home Manager inside NixOS. With flakes defined as inputs

This works, a stylix config.

  stylix = {
    image = ./wallpapers/Bones.png;
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";
    autoEnable = false;
    targets = {
      bspwm.enable = false;
      nixvim.enable = false;
      kitty.enable = false; #kitty does not apply base16 Colorscheme, as intended
      xfce.enable = true;
      vesktop.enable = true; #vesktop applies colorscheme 
    };
};

Here is Kitty config with defined colors that works perfectly fine if I disable Stylix or autoEnable

{pkgs, config, inputs, ...}:

{
  programs.kitty = {
    enable = true;
    settings = {
#kitty.conf
      enable_audio_bell = false;
      shell = ''fish'';
      url_style = ''single'';
      cursor_shape = ''block'';
      scrollback_lines = 2000;
      confirm_os_window_close = 0;
      font_size = 11;
      background = ''#181B28'';
      foreground = ''#F8F8F2'';
      selection_foreground = ''#1E1F28'';
      selection_background = ''#44475A'';
      color0 = ''#000000''; # Black
        color1 = ''#FF5555''; # RED
        color2 = ''#50FA7B''; # GREEN
        color3 = ''#DA00E9''; # HIGHLIGH
        color4 = ''#BD92F8''; # BLUE
        color5 = ''#FF78C5''; # MAGENTA
        color6 = ''#8AE9FC''; # CYAN
        color7 = ''#BBBBBB''; # WHITE
        color8 = ''#545454''; # BR BLACK
        color9 = ''#FF5454''; # BR RED
        color10 = ''#50FA7B''; # BR GREEN
        color11 = ''#F0FA8B''; # BR YELLOW
        color12 = ''#BD92F8''; # BR BLUE
        color13 = ''#FF78C5''; # BR MAGENTA
        color14 = ''#8AE9FC''; # BR CYAN
        color15 = ''#FFFFFF''; # BR WHITE
        url_color = ''#0087BD''; #URL
        cursor = ''#F4DBD6'';
      cursor_text_color = ''#24273A'';
      active_border_color = ''#B7BDF8'';
      inactive_border_color = ''#6E738D'';
      bell_border_color = ''#EED49F'';
      active_tab_foreground = "#181926";
      active_tab_background = "#C6A0F6";
      inactive_tab_foreground = "#CAD3F5";
      inactive_tab_background = "#1E2030";
      tab_bar_background = "#181926";
    };
  };
}
danth commented 1 month ago

The kitty theme is imported using extraConfig here:

https://github.com/danth/stylix/blob/00a11ba2f0b52f761c0bc77daebb00cb4d44ba09/modules/kitty/hm.nix#L30-L32

Perhaps something is overriding this? I know that in some cases using settings can disable anything in extraConfig.

Ladas552 commented 1 month ago

So, I tried to comment out the whole kitty.nix I got and just left the programs.kitty.enable = true;, as @danth assumed would work. Rebuild, and Stylix started to work properly. Then I Uncommented the whole thing back. And rebuild. Stylix still follows the targets.kitty.enable=false even with autoEnable = true.

I don't know why it didn't work the first time, but if anything, unloading my kitty file module helped. Thanks for your attention, this was a weird bug.

trueNAHO commented 1 month ago

The kitty theme is imported using extraConfig here:

https://github.com/danth/stylix/blob/00a11ba2f0b52f761c0bc77daebb00cb4d44ba09/modules/kitty/hm.nix#L30-L32

Perhaps something is overriding this? I know that in some cases using settings can disable anything in extraConfig.

As usual, Home Manager inserts the extraConfig at the end of the generated configuration file: https://github.com/nix-community/home-manager/blob/release-23.11/modules/programs/kitty.nix#L202-L205.

However, the use of extraConfig might cause other potentially related issues. As discussed in https://github.com/danth/stylix/issues/159#issuecomment-1937879216, it makes it harder to override options, and as discussed in https://github.com/danth/stylix/pull/388#issuecomment-2126947630, it makes it easier to accidentally override Stylix options.

I don't know why it didn't work the first time, but if anything, unloading my kitty file module helped. Thanks for your attention, this was a weird bug.

It could be that this was caused by the fact that the Stylix generated theme is injected at the end of the configuration file.

Ladas552 commented 1 month ago

As I happen to test a minute ago, it could have been happening because fish shell can change the colors of terminal, and got changed by stylix, therefore applying the colorscheme onto kitty. And it is not reversed back when exiting to bash it seems. Sorry for bothering