From 1bdee080c6a016510b362dbed88f89a7017c835a Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 16 Oct 2023 13:50:12 +0100 Subject: [PATCH] home-manager/theme: add symbols font --- home-manager/cli/nnn.nix | 19 ++++++++++++++----- home-manager/desktop/kitty.nix | 3 +-- home-manager/desktop/sway/waybar.nix | 12 +++++++++--- home-manager/desktop/theme/default.nix | 14 ++++++++++++-- home-manager/editor/neovim.nix | 2 +- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/home-manager/cli/nnn.nix b/home-manager/cli/nnn.nix index 5027226f..39f58d17 100644 --- a/home-manager/cli/nnn.nix +++ b/home-manager/cli/nnn.nix @@ -2,18 +2,27 @@ let inherit (flake) inputs; + cfg = config.home-manager.cli.nnn; in { - options.home-manager.cli.nnn.enable = lib.mkEnableOption "nnn config" // { - default = config.home-manager.cli.enable; + options.home-manager.cli.nnn = { + enable = lib.mkEnableOption "nnn config" // { + default = config.home-manager.cli.enable; + }; + # Do not forget to set 'Hack Nerd Mono Font' as the terminal font + enableIcons = lib.mkEnableOption "icons" // { + default = config.home-manager.desktop.enable || config.home-manager.darwin.enable; + }; }; - config = lib.mkIf config.home-manager.cli.nnn.enable { - home.packages = [ (pkgs.nerdfonts.override { fonts = [ "Hack" ]; }) ]; + config = lib.mkIf cfg.enable { + home.packages = lib.optionals cfg.enableIcons [ + config.home-manager.desktop.theme.fonts.symbols.package + ]; programs.nnn = { enable = true; - package = pkgs.nnn.override { withNerdIcons = true; }; + package = pkgs.nnn.override { withNerdIcons = cfg.enableIcons; }; bookmarks = { d = "~/Documents"; D = "~/Downloads"; diff --git a/home-manager/desktop/kitty.nix b/home-manager/desktop/kitty.nix index 7325b642..3ee4cbe0 100644 --- a/home-manager/desktop/kitty.nix +++ b/home-manager/desktop/kitty.nix @@ -10,8 +10,7 @@ enable = true; keybindings = { "ctrl+shift+0" = "change_font_size all 0"; }; font = { - package = pkgs.nerdfonts.override { fonts = [ "Hack" ]; }; - name = "Hack Nerd Font"; + inherit (config.home-manager.desktop.theme.fonts.symbols) package name; }; settings = with config.home-manager.desktop.theme.colors; { # Font diff --git a/home-manager/desktop/sway/waybar.nix b/home-manager/desktop/sway/waybar.nix index b43484bb..14df3d4a 100644 --- a/home-manager/desktop/sway/waybar.nix +++ b/home-manager/desktop/sway/waybar.nix @@ -234,12 +234,18 @@ in }; }; }; - # TODO: get fonts from config.home-manager.desktop.theme.fonts - style = with config.home-manager.desktop.theme.colors; '' + style = with config.home-manager.desktop.theme.colors; with config.home-manager.desktop.theme.fonts; let + concatFonts = fonts: lib.pipe fonts [ + lib.flatten + (map (s: ''"${s}"'')) + (lib.concatStringsSep ", ") + ]; + in + '' * { border: none; border-radius: 0; - font-family: Roboto, "Font Awesome 6 Free Solid", "Symbols Nerd Font"; + font-family: ${concatFonts [ gui.name icons.name "Symbols Nerd Font" ]}; } window#waybar { background: ${base00}; diff --git a/home-manager/desktop/theme/default.nix b/home-manager/desktop/theme/default.nix index 4c676b7a..baf2e742 100644 --- a/home-manager/desktop/theme/default.nix +++ b/home-manager/desktop/theme/default.nix @@ -23,7 +23,7 @@ in fonts = { gui = lib.mkOption { type = lib.types.nullOr themeType; - description = "GUI main font"; + description = "GUI font"; default = { package = pkgs.roboto; name = "Roboto"; @@ -32,7 +32,7 @@ in icons = lib.mkOption { type = lib.types.nullOr themeType; - description = "Icons main font"; + description = "Icons font"; default = { package = pkgs.font-awesome_6; name = [ @@ -42,6 +42,15 @@ in }; }; + symbols = lib.mkOption { + type = lib.types.nullOr themeType; + description = "Symbols font"; + default = { + package = pkgs.nerdfonts.override { fonts = [ "Hack" ]; }; + name = "Hack Nerd Font"; + }; + }; + dpi = lib.mkOption { type = lib.types.int; description = "Font dpi"; @@ -78,6 +87,7 @@ in dejavu_fonts fonts.gui.package fonts.icons.package + fonts.symbols.package gnome.gnome-themes-extra hack-font hicolor-icon-theme diff --git a/home-manager/editor/neovim.nix b/home-manager/editor/neovim.nix index 43971246..04e550e3 100644 --- a/home-manager/editor/neovim.nix +++ b/home-manager/editor/neovim.nix @@ -26,7 +26,7 @@ in ripgrep ] ++ lib.optionals cfg.enableIcons [ - (nerdfonts.override { fonts = [ "Hack" ]; }) + config.home-manager.desktop.theme.fonts.symbols.package ]; programs.neovim = {