Significant progress on font customization
This commit is contained in:
		
							parent
							
								
									5f66c1c631
								
							
						
					
					
						commit
						472731c514
					
				
							
								
								
									
										36
									
								
								merged.nix
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								merged.nix
									
									
									
									
									
								
							| @ -232,29 +232,29 @@ in { | |||||||
|     my-wqy-zenhei |     my-wqy-zenhei | ||||||
|     my-wqy-microhei |     my-wqy-microhei | ||||||
|     my-wqy-bitmapsong |     my-wqy-bitmapsong | ||||||
|     cozette |     # cozette | ||||||
|     #uw-ttyp0 |     #uw-ttyp0 | ||||||
|     #ucs-fonts |     #ucs-fonts | ||||||
|     dina-font # Cool but too small :( |     # dina-font # Cool but too small :( | ||||||
|     #unifont # Replace with Kissinger2 |     #unifont # Replace with Kissinger2 | ||||||
|     #unifont_upper # Replace with Kissinger 2 |     #unifont_upper # Replace with Kissinger 2 | ||||||
|     (nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; }) |     # (nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; }) | ||||||
|   ]; |   ]; | ||||||
|   fonts.fontconfig.defaultFonts = { |   # fonts.fontconfig.defaultFonts = { | ||||||
|     serif = [ |   #   serif = [ | ||||||
|       "DejaVu Serif" |   #     # "DejaVu Serif" | ||||||
|     ]; |   #   ]; | ||||||
|     sansSerif = [ |   #   sansSerif = [ | ||||||
|       "DejaVu Sans" |   #     # "DejaVu Sans" | ||||||
|     ]; |   #   ]; | ||||||
|     monospace = [ |   #   monospace = [ | ||||||
|       "Dina" |   #     # "Dina" | ||||||
|     ]; |   #   ]; | ||||||
|     emoji = [ |   #   emoji = [ | ||||||
|       "CozetteVector" |   #     # "Cozette Vector" | ||||||
|       "Noto Color Emoji" |   #     # "Noto Color Emoji" | ||||||
|     ]; |   #   ]; | ||||||
|   }; |   # }; | ||||||
|   fonts.fontconfig.localConf = '' |   fonts.fontconfig.localConf = '' | ||||||
|     <alias> |     <alias> | ||||||
|       <family>Dina</family> |       <family>Dina</family> | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     ./discord/default.nix |     ./discord/default.nix | ||||||
|     ./feishin/default.nix |     ./feishin/default.nix | ||||||
|     ./firefox/default.nix |     ./firefox/default.nix | ||||||
|  |     ./fontconfig/default.nix | ||||||
|     ./obsidian/default.nix |     ./obsidian/default.nix | ||||||
|     ./shell/bash.nix |     ./shell/bash.nix | ||||||
|     ./shell/fish.nix |     ./shell/fish.nix | ||||||
|  | |||||||
							
								
								
									
										31
									
								
								modules/users/modules/fontconfig/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								modules/users/modules/fontconfig/default.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | { lib, config, pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | with lib; | ||||||
|  | let | ||||||
|  |   cfg = config.modules.fontconfig; | ||||||
|  | in { | ||||||
|  |   options.modules.fontconfig = { | ||||||
|  |     enable = mkEnableOption "fontconfig"; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = mkIf cfg.enable { | ||||||
|  |     fonts.fontconfig = { | ||||||
|  |       enable = true; | ||||||
|  | 
 | ||||||
|  |       defaultFonts = { | ||||||
|  |         serif = [ | ||||||
|  |           config.theming.fonts.serif.name | ||||||
|  |         ]; | ||||||
|  |         sansSerif = [ | ||||||
|  |           config.theming.fonts.sansSerif.name | ||||||
|  |         ]; | ||||||
|  |         monospace = [ | ||||||
|  |           config.theming.fonts.monospace.name | ||||||
|  |         ]; | ||||||
|  |         emoji = [ | ||||||
|  |           config.theming.fonts.emoji.name | ||||||
|  |         ]; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
| @ -2,6 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| with lib; | with lib; | ||||||
| let | let | ||||||
|  |   cfg = config.theming; | ||||||
|  | 
 | ||||||
|   # Stylix |   # Stylix | ||||||
|   stylix = pkgs.fetchFromGitHub { |   stylix = pkgs.fetchFromGitHub { | ||||||
|     owner = "danth"; |     owner = "danth"; | ||||||
| @ -9,6 +11,69 @@ let | |||||||
|     rev = "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116"; |     rev = "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116"; | ||||||
|     sha256 = "0dz8h1ga8lnfvvmvsf6iqvnbvxrvx3qxi0y8s8b72066mqgvy8y5"; |     sha256 = "0dz8h1ga8lnfvvmvsf6iqvnbvxrvx3qxi0y8s8b72066mqgvy8y5"; | ||||||
|   }; |   }; | ||||||
|  | 
 | ||||||
|  |   # Font module type | ||||||
|  |   fontModule = types.submodule { | ||||||
|  |     options = { | ||||||
|  |       name = mkOption { | ||||||
|  |         type = types.str; | ||||||
|  |         description = "Font family name."; | ||||||
|  |       }; | ||||||
|  |       package = mkOption { | ||||||
|  |         type = types.anything; | ||||||
|  |         description = "Font package"; | ||||||
|  |       }; | ||||||
|  |       recommendedSize = mkOption { | ||||||
|  |         type = types.nullOr types.int; | ||||||
|  |         default = null; | ||||||
|  |         description = "Recommended size for displaying this font."; | ||||||
|  |       }; | ||||||
|  |       fallbackFonts = mkOption { | ||||||
|  |         type = types.listOf types.str; | ||||||
|  |         default = []; | ||||||
|  |         description = "Fallback fonts for specified font."; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   fontModules = [ | ||||||
|  |     # Import all fonts | ||||||
|  |     ./fonts/cozette-vector.nix | ||||||
|  |     ./fonts/cozette.nix | ||||||
|  |     ./fonts/dejavu-sans.nix | ||||||
|  |     ./fonts/dejavu-serif.nix | ||||||
|  |     ./fonts/dina.nix | ||||||
|  |     ./fonts/fira-code.nix | ||||||
|  |     ./fonts/nerd-fonts-symbols.nix | ||||||
|  |     ./fonts/noto-color-emoji.nix | ||||||
|  |   ]; | ||||||
|  | 
 | ||||||
|  |   # Gather enabled fonts. | ||||||
|  |   enabledFonts = [ | ||||||
|  |     cfg.fonts.serif.name | ||||||
|  |     cfg.fonts.sansSerif.name | ||||||
|  |     cfg.fonts.monospace.name | ||||||
|  |     cfg.fonts.emoji.name | ||||||
|  |   ] ++ map (font: font.name) cfg.fonts.extraFonts; | ||||||
|  | 
 | ||||||
|  |   # Flatten dependencies of fonts | ||||||
|  |   fontPackages = converge (fonts: | ||||||
|  |     listToAttrs (map (font: { | ||||||
|  |       name = font; | ||||||
|  |       value = true; | ||||||
|  |     }) ( | ||||||
|  |       flatten (map (font:  | ||||||
|  |         [ font.name ] | ||||||
|  |         ++ cfg.fonts.pkgs.${font.name}.fallbackFonts | ||||||
|  |       ) (attrsToList fonts)) | ||||||
|  |     )) | ||||||
|  |   ) (listToAttrs (map (font: { | ||||||
|  |     name = font; | ||||||
|  |     value = true; | ||||||
|  |   }) enabledFonts)); | ||||||
|  | 
 | ||||||
|  |   # Convert set of fonts to list of packages | ||||||
|  |   fontPackageList = map (font: cfg.fonts.pkgs.${font.name}.package) (attrsToList (traceVal fontPackages)); | ||||||
| in { | in { | ||||||
|   imports = [ |   imports = [ | ||||||
|     # Import all themes |     # Import all themes | ||||||
| @ -16,10 +81,15 @@ in { | |||||||
|     ./themes/catppuccin.nix |     ./themes/catppuccin.nix | ||||||
|   ]; |   ]; | ||||||
| 
 | 
 | ||||||
|   options.theming = |   options.testing.test = mkOption { | ||||||
|   let  |     type = types.anything; | ||||||
|     colors = config.theming.schemeColors; |     default = traced; | ||||||
|   in  { |     description = "Wowzah"; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   options.modules.theming.enable = mkEnableOption "theming"; | ||||||
|  | 
 | ||||||
|  |   options.theming = let colors = config.theming.schemeColors; in { | ||||||
|     darkMode = mkOption { |     darkMode = mkOption { | ||||||
|       type = types.bool; |       type = types.bool; | ||||||
|       default = false; |       default = false; | ||||||
| @ -69,15 +139,67 @@ in { | |||||||
|         description = "Margin of each window, actual space between windows will be twice this number."; |         description = "Margin of each window, actual space between windows will be twice this number."; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|  |     fonts = { | ||||||
|  |       pkgs = mkOption { | ||||||
|  |         type = types.attrsOf fontModule; | ||||||
|  |         default = builtins.listToAttrs (map (module: { | ||||||
|  |           name = module.name; | ||||||
|  |           value = module; | ||||||
|  |         }) (map (module: (import module) { inherit lib config pkgs; }) fontModules)); | ||||||
|  |         description = "All available font modules."; | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|   config = { |       serif = mkOption { | ||||||
|  |         type = fontModule; | ||||||
|  |         description = "Default serif font"; | ||||||
|  |       }; | ||||||
|  |        | ||||||
|  |       sansSerif = mkOption { | ||||||
|  |         type = fontModule; | ||||||
|  |         description = "Default sansSerif font."; | ||||||
|  |       }; | ||||||
|  |        | ||||||
|  |       monospace = mkOption { | ||||||
|  |         type = fontModule; | ||||||
|  |         description = "Default monospace font."; | ||||||
|  |       }; | ||||||
|  |        | ||||||
|  |       emoji = mkOption { | ||||||
|  |         type = fontModule; | ||||||
|  |         description = "Default emoji font."; | ||||||
|  |       }; | ||||||
|  | 
 | ||||||
|  |       extraFonts = mkOption { | ||||||
|  |         type = types.listOf fontModule; | ||||||
|  |         default = []; | ||||||
|  |         description = "Additional fonts to install."; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = mkIf config.modules.theming.enable { | ||||||
|  |     # Enable fontconfig | ||||||
|  |     modules.fontconfig.enable = true; | ||||||
|  | 
 | ||||||
|  |     # Install configured fonts | ||||||
|  |     home.packages = fontPackageList; | ||||||
|  | 
 | ||||||
|  |     # Enable stylix | ||||||
|  |     # TODO: Move to own module | ||||||
|     stylix = { |     stylix = { | ||||||
|       enable = true; |       enable = true; | ||||||
|       autoEnable = false; |       autoEnable = false; | ||||||
| 
 | 
 | ||||||
|       base16Scheme = config.theming.colorScheme; |       base16Scheme = cfg.colorScheme; | ||||||
|       polarity = if config.theming.darkMode then "dark" else "light"; |       polarity = if cfg.darkMode then "dark" else "light"; | ||||||
|  | 
 | ||||||
|  |       fonts = { | ||||||
|  |         serif = getAttrs [ "name" "package" ] cfg.fonts.serif; | ||||||
|  |         sansSerif = getAttrs [ "name" "package" ] cfg.fonts.sansSerif; | ||||||
|  |         monospace = getAttrs [ "name" "package" ] cfg.fonts.monospace; | ||||||
|  |         emoji = getAttrs [ "name" "package" ] cfg.fonts.emoji; | ||||||
|  |       }; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								modules/users/modules/theming/fonts/cozette-vector.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								modules/users/modules/theming/fonts/cozette-vector.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Cozette Vector"; | ||||||
|  |   package = pkgs.cozette; | ||||||
|  |   recommendedSize = 9; | ||||||
|  |   fallbackFonts = [ | ||||||
|  |   ]; | ||||||
|  | } | ||||||
							
								
								
									
										10
									
								
								modules/users/modules/theming/fonts/cozette.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/users/modules/theming/fonts/cozette.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Cozette"; | ||||||
|  |   package = pkgs.cozette; | ||||||
|  |   recommendedSize = 9; | ||||||
|  |   fallbackFonts = [ | ||||||
|  |     "Cozette Vector" | ||||||
|  |   ]; | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								modules/users/modules/theming/fonts/dejavu-sans.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								modules/users/modules/theming/fonts/dejavu-sans.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "DejaVu Sans"; | ||||||
|  |   package = pkgs.dejavu_fonts; | ||||||
|  |   recommendedSize = 12; | ||||||
|  |   fallbackFonts = []; | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								modules/users/modules/theming/fonts/dejavu-serif.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								modules/users/modules/theming/fonts/dejavu-serif.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "DejaVu Serif"; | ||||||
|  |   package = pkgs.dejavu_fonts; | ||||||
|  |   recommendedSize = 12; | ||||||
|  |   fallbackFonts = []; | ||||||
|  | } | ||||||
							
								
								
									
										10
									
								
								modules/users/modules/theming/fonts/dina.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/users/modules/theming/fonts/dina.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Dina"; | ||||||
|  |   package = pkgs.dina-font; | ||||||
|  |   recommendedSize = 9; | ||||||
|  |   fallbackFonts = [ | ||||||
|  |     "Cozette" | ||||||
|  |   ]; | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								modules/users/modules/theming/fonts/fira-code.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								modules/users/modules/theming/fonts/fira-code.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Fira Code"; | ||||||
|  |   package = pkgs.fira-code; | ||||||
|  |   recommendedSize = 12; | ||||||
|  |   fallbackFonts = []; | ||||||
|  | } | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Symbols Nerd Font Mono"; | ||||||
|  |   package = pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }; | ||||||
|  |   recommendedSize = 12; | ||||||
|  |   fallbackFonts = []; | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								modules/users/modules/theming/fonts/noto-color-emoji.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								modules/users/modules/theming/fonts/noto-color-emoji.nix
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | { pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  |   name = "Noto Color Emoji"; | ||||||
|  |   package = pkgs.noto-fonts-color-emoji; | ||||||
|  |   recommendedSize = 12; | ||||||
|  |   fallbackFonts = []; | ||||||
|  | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| # How Jan likes his linux to be configured | # How Jan likes his linux to be configured | ||||||
| 
 | 
 | ||||||
| { ... }: | { config, ... }: | ||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   imports = [ |   imports = [ | ||||||
| @ -11,11 +11,15 @@ | |||||||
|     # State version |     # State version | ||||||
|     home.stateVersion = "24.05"; |     home.stateVersion = "24.05"; | ||||||
| 
 | 
 | ||||||
|  |     # Enabled modules | ||||||
|     modules = { |     modules = { | ||||||
|       # Window manager |       # Window manager | ||||||
|       river.enable = true; |       river.enable = true; | ||||||
|       waylock.enable = true; |       waylock.enable = true; | ||||||
| 
 | 
 | ||||||
|  |       # Theming | ||||||
|  |       theming.enable = true; | ||||||
|  | 
 | ||||||
|       # Programs |       # Programs | ||||||
|       feishin.enable = true; |       feishin.enable = true; | ||||||
|       firefox.enable = true; |       firefox.enable = true; | ||||||
| @ -29,15 +33,21 @@ | |||||||
|       unfree.enable = true; |       unfree.enable = true; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     theming.themes.gruvbox = { |     # Theme configuration | ||||||
|       enable = false; |     theming = let fontpkgs = config.theming.fonts.pkgs; in { | ||||||
|       darkMode = false; |       # Fonts | ||||||
|       contrast = "hard"; |       fonts.serif = fontpkgs."DejaVu Serif"; | ||||||
|     }; |       fonts.sansSerif = fontpkgs."DejaVu Sans"; | ||||||
|  |       fonts.monospace = fontpkgs."Dina"; | ||||||
|  |       fonts.emoji = fontpkgs."Dina"; | ||||||
|  |       fonts.extraFonts = [ | ||||||
|  |       ]; | ||||||
| 
 | 
 | ||||||
|     theming.themes.catppuccin = { |       # Color scheme | ||||||
|  |       themes.catppuccin = { | ||||||
|         enable = true; |         enable = true; | ||||||
|         flavor = "latte"; |         flavor = "latte"; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|  |   }; | ||||||
| } | } | ||||||
|  | |||||||
| @ -57,10 +57,10 @@ in { | |||||||
| 
 | 
 | ||||||
|     # base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; |     # base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; | ||||||
|     fonts = { |     fonts = { | ||||||
|       monospace = { |       # monospace = { | ||||||
|         package = pkgs.dina-font; |       #   package = pkgs.dina-font; | ||||||
|         name = "Dina"; |       #   name = "Dina"; | ||||||
|       }; |       # }; | ||||||
| 
 | 
 | ||||||
|       sizes = { |       sizes = { | ||||||
|         terminal = 9; |         terminal = 9; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jan Bulthuis
						Jan Bulthuis