danth / stylix

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

stylix: delegate default font declarations #366

Open trueNAHO opened 1 month ago

trueNAHO commented 1 month ago

The

Stylix options 2 should be removed since NixOS 1 and Home Manager 3 provide the same

options.

This would close the following tickets:

danth commented 1 month ago

Some apps don't respect fontconfig, which is why Stylix has its own options which build on top of fontconfig but also configure those unsupported apps explicitly.

trueNAHO commented 1 month ago

Some apps don't respect fontconfig, which is why Stylix has its own options which build on top of fontconfig but also configure those unsupported apps explicitly.

In that case, the

options should default to the fonts.fontconfig.defaultFonts values for NixOS and Home Manager. Currently, Stylix hard-codes the Home Manager default value.

Considering that the Home Manager fonts.fontconfig.defaultFonts values default to [], what should Stylix do when this value is []? Either we provide a hard-coded fallback or we do not declare fonts in that case. Since Stylix aims to provide a coherent experience, it might be better to provide a fallback but try the fonts.fontconfig.defaultFonts value from Home Manager.

danth commented 1 month ago

Perhaps we should simply do nothing for an empty list. This would coincide with supporting null values for other options, which has been suggested in the past as an alternative to a global stylix.enable option.

I support removing the current defaults since they can make desktop environments which have their own standard font, such as GNOME, look unusual unless the user knows the name of that standard font and explicitly chooses it.

trueNAHO commented 1 month ago

Perhaps we should simply do nothing for an empty list. This would coincide with supporting null values for other options, which has been suggested in the past as an alternative to a global stylix.enable option.

I support removing the current defaults since they can make desktop environments which have their own standard font, such as GNOME, look unusual unless the user knows the name of that standard font and explicitly chooses it.

Yes, not declaring fonts when the fonts.fontconfig.defaultFonts values are set to [] would be the least controversial and best solution.

In conclusion we declare fonts.fontconfig.defaultFonts as the default in all cases, and do not declare the fonts in Stylix applications when they are set to [].

ernestha commented 2 weeks ago

I'm writing here since this discussion might be related to my issue and maybe you guys can clear that up. If it is not, please let me know and I"ll turn somewhere else for help.

I just installed Stylix yesterday both in my NixOS as well as my Home Manager config (I have HM set up as standalone). It works well for the most part, but when trying to set default fonts, I encounter errors both during nixos-rebuild and during home-manager switch. In HM, I have also set up fonts.fontconfig for my user. In NixOS, that is not the case.

I have used the example from the Stylix book in my config (this is part of a file imported by my HM config):

{ config, pkgs, ... }:

{
    stylix.enable = true;

   ... omitted for brevity ...

    # Fonts config
    stylix.fonts = {
        #  monospace = {
        #          package = pkgs.nerdfonts.override { fonts = [ “Meslo” ]; };
        #          name = “MesloLGS Nerd Font”;
        #       };
          sansSerif = {
                  package = pkgs.dejavu_fonts;
                  name = “DejaVu Sans”;
          };
          serif = {
                  package = pkgs.dejavu_fonts;
                  name = “DejaVu Serif”;
          };
    };
}

The monospace part is commented out b/c I thought originally, that the error was related to my override.

When running home-manager switch, I get the following error on all the lines name = ...: "error: syntax error, unexpected invalid token". The same happens on the system level with the same config.

I am pretty new to Nix, but I thought I was able to figure out at least syntax errors. However, this gives me a headache. Could it be related to fonts.fontconfig being enabled? Or is there something else I am missing?

Thanks in advance for any help or advice!

trueNAHO commented 2 weeks ago
    stylix.fonts = {
        #  monospace = {
        #          package = pkgs.nerdfonts.override { fonts = [ “Meslo” ]; };
        #          name = “MesloLGS Nerd Font”;
        #       };
          sansSerif = {
                  package = pkgs.dejavu_fonts;
                  name = “DejaVu Sans”;
          };
          serif = {
                  package = pkgs.dejavu_fonts;
                  name = “DejaVu Serif”;
          };
    };

I get the following error on all the lines name = ...: "error: syntax error, unexpected invalid token". The same happens on the system level with the same config.

Try replacing the (U+201C) and (U+201D) characters with " (U+0022).

ernestha commented 2 weeks ago

@trueNAHO: Oh wow, I did not spot that. That's what you get from copy-pasting, I guess :) Thank you so much! And sorry for hijacking this thread with that oversight.