diff --git a/home-manager/desktop/dunst.nix b/home-manager/desktop/dunst.nix index 59e06386..045bd084 100644 --- a/home-manager/desktop/dunst.nix +++ b/home-manager/desktop/dunst.nix @@ -14,7 +14,7 @@ services.dunst = { enable = true; iconTheme = with config.gtk.iconTheme; { inherit name package; }; - settings = with config.theme.colors; + settings = with config.home-manager.desktop.theme.colors; let theme = { background = base00; @@ -22,7 +22,7 @@ }; in { - global = with config.theme.fonts; { + global = with config.home-manager.desktop.theme.fonts; { font = "${gui.name} 8"; markup = true; format = "%s\\n%b"; diff --git a/home-manager/desktop/i3/common.nix b/home-manager/desktop/i3/common.nix index 987a53b5..4eab6d9f 100644 --- a/home-manager/desktop/i3/common.nix +++ b/home-manager/desktop/i3/common.nix @@ -14,7 +14,7 @@ , statusCommand ? null , alt ? "Mod1" , modifier ? "Mod4" -, bars ? with config.theme.colors; [{ +, bars ? with config.home-manager.desktop.theme.colors; [{ inherit fonts statusCommand; position = "top"; @@ -49,7 +49,7 @@ }; }; }] -, fonts ? with config.theme.fonts; { +, fonts ? with config.home-manager.desktop.theme.fonts; { names = lib.flatten [ gui.name icons.name @@ -152,7 +152,7 @@ in config = { inherit bars fonts modifier menu terminal; - colors = with config.theme.colors; { + colors = with config.home-manager.desktop.theme.colors; { background = base07; focused = { background = base0D; diff --git a/home-manager/desktop/i3/i3status-rust.nix b/home-manager/desktop/i3/i3status-rust.nix index 124c7de6..6530dad3 100644 --- a/home-manager/desktop/i3/i3status-rust.nix +++ b/home-manager/desktop/i3/i3status-rust.nix @@ -40,7 +40,7 @@ in settings = { theme = { theme = "plain"; - overrides = with config.theme.colors; { + overrides = with config.home-manager.desktop.theme.colors; { idle_bg = base00; idle_fg = base05; info_bg = base0D; diff --git a/home-manager/desktop/i3/rofi.nix b/home-manager/desktop/i3/rofi.nix index 87c32e47..f57bb1e2 100644 --- a/home-manager/desktop/i3/rofi.nix +++ b/home-manager/desktop/i3/rofi.nix @@ -10,11 +10,11 @@ enable = true; terminal = "${config.programs.kitty.package}/bin/kitty"; package = with pkgs; rofi.override { plugins = [ rofi-calc rofi-emoji ]; }; - font = with config.theme.fonts; "${gui.package} 14"; + font = with config.home-manager.desktop.theme.fonts; "${gui.package} 14"; theme = let l = config.lib.formats.rasi.mkLiteral; in - with config.theme.colors; { + with config.home-manager.desktop.theme.colors; { "*" = { background-color = l base00; border-color = l base01; diff --git a/home-manager/desktop/i3/screen-locker.nix b/home-manager/desktop/i3/screen-locker.nix index 8d004bf5..0a47b1ce 100644 --- a/home-manager/desktop/i3/screen-locker.nix +++ b/home-manager/desktop/i3/screen-locker.nix @@ -9,7 +9,7 @@ services.screen-locker = { enable = true; inactiveInterval = 10; - lockCmd = with config.theme.fonts; toString + lockCmd = with config.home-manager-desktop.theme.fonts; toString (pkgs.writeShellScript "lock-screen" '' export XSECURELOCK_FORCE_GRAB=1 export XSECURELOCK_BLANK_DPMS_STATE="off" diff --git a/home-manager/desktop/i3/wallpaper.nix b/home-manager/desktop/i3/wallpaper.nix index ac3246b4..6fdbcc41 100644 --- a/home-manager/desktop/i3/wallpaper.nix +++ b/home-manager/desktop/i3/wallpaper.nix @@ -16,12 +16,12 @@ Install.WantedBy = [ "graphical-session.target" ]; - Service = { + Service = with config.home-manager.desktop.theme.wallpaper; { ExecStart = lib.concatStringsSep " " [ "${lib.getExe pkgs.feh}" "--no-fehbg" - "--bg-${config.theme.wallpaper.scale}" - "${config.theme.wallpaper.path}" + "--bg-${scale}" + "${path}" ]; Type = "oneshot"; }; diff --git a/home-manager/desktop/i3/x11.nix b/home-manager/desktop/i3/x11.nix index 7a16f35e..c345d27f 100644 --- a/home-manager/desktop/i3/x11.nix +++ b/home-manager/desktop/i3/x11.nix @@ -16,7 +16,7 @@ in home.file.".xinitrc".source = config.lib.file.mkOutOfStoreSymlink xsession; xdg.configFile."sx/sxrc".source = config.lib.file.mkOutOfStoreSymlink xsession; - xresources.properties = with config.theme.fonts; { + xresources.properties = with config.home-manager.desktop.theme.fonts; { "Xft.dpi" = toString dpi; }; diff --git a/home-manager/desktop/kitty.nix b/home-manager/desktop/kitty.nix index 7f6f8437..7325b642 100644 --- a/home-manager/desktop/kitty.nix +++ b/home-manager/desktop/kitty.nix @@ -13,7 +13,7 @@ package = pkgs.nerdfonts.override { fonts = [ "Hack" ]; }; name = "Hack Nerd Font"; }; - settings = with config.theme.colors; { + settings = with config.home-manager.desktop.theme.colors; { # Font font_size = "12.0"; diff --git a/home-manager/desktop/sway/default.nix b/home-manager/desktop/sway/default.nix index a2e556fe..bec7b66a 100644 --- a/home-manager/desktop/sway/default.nix +++ b/home-manager/desktop/sway/default.nix @@ -87,8 +87,8 @@ in }; output = { - "*" = { - bg = "${config.theme.wallpaper.path} ${config.theme.wallpaper.scale}"; + "*" = with config.home-manageer.desktop.theme.wallpaper; { + bg = "${path} ${scale}"; # DPI scale = toString (125 / 100.0); } // lib.optionalAttrs (osConfig ? fonts.fontconfig) { diff --git a/home-manager/desktop/sway/fuzzel.nix b/home-manager/desktop/sway/fuzzel.nix index 94a2bdd1..49e03aac 100644 --- a/home-manager/desktop/sway/fuzzel.nix +++ b/home-manager/desktop/sway/fuzzel.nix @@ -7,7 +7,7 @@ config = lib.mkIf config.home-manager.desktop.sway.fuzzel.enable { programs.fuzzel = { enable = true; - settings = with config.theme.fonts; { + settings = with config.home-manager.desktop.theme.fonts; { main = { font = "${gui.name}:style=regular:size=14"; terminal = "${config.programs.kitty.package}/bin/kitty"; @@ -17,7 +17,7 @@ vertical-pad = 10; line-height = 28; }; - colors = with config.theme.colors; let + colors = with config.home-manager.desktop.theme.colors; let fixColor = color: "${lib.removePrefix "#" color}ff"; in { diff --git a/home-manager/desktop/sway/swaylock.nix b/home-manager/desktop/sway/swaylock.nix index 68f276a8..abf4abb1 100644 --- a/home-manager/desktop/sway/swaylock.nix +++ b/home-manager/desktop/sway/swaylock.nix @@ -9,16 +9,16 @@ programs.swaylock = { enable = true; package = pkgs.swaylock; - settings = with config.theme.colors; { - font = config.theme.fonts.gui.name; + settings = with config.home-manager.desktop.theme.colors; { + font = config.home-manager.desktop.theme.fonts.gui.name; indicator-caps-lock = true; show-keyboard-layout = true; # https://stackoverflow.com/a/506662 image = with pkgs; toString (runCommand "wallpaper-pixelated" { buildInputs = [ imagemagick ]; } '' - convert -scale 1% -scale 10000% ${config.theme.wallpaper.path} $out + convert -scale 1% -scale 10000% ${config.home-manager.desktop.theme.wallpaper.path} $out ''); - scaling = config.theme.wallpaper.scale; + scaling = config.home-manager.desktop.theme.wallpaper.scale; inside-color = base01; line-color = base01; diff --git a/home-manager/desktop/sway/waybar.nix b/home-manager/desktop/sway/waybar.nix index aa21afcf..b43484bb 100644 --- a/home-manager/desktop/sway/waybar.nix +++ b/home-manager/desktop/sway/waybar.nix @@ -234,7 +234,8 @@ in }; }; }; - style = with config.theme.colors; '' + # TODO: get fonts from config.home-manager.desktop.theme.fonts + style = with config.home-manager.desktop.theme.colors; '' * { border: none; border-radius: 0; diff --git a/home-manager/desktop/theme/default.nix b/home-manager/desktop/theme/default.nix index b3ea70e2..4c676b7a 100644 --- a/home-manager/desktop/theme/default.nix +++ b/home-manager/desktop/theme/default.nix @@ -1,18 +1,39 @@ { config, pkgs, lib, osConfig, ... }: -{ - options.home-manager.desktop.theme.enable = lib.mkEnableOption "Chromium config" // { - default = config.home-manager.desktop.enable; - }; +let + themeType = lib.types.submodule { + options = { + package = lib.mkOption { + type = with lib.types; nullOr package; + description = "Theme package"; + }; - config = lib.mkIf config.home-manager.desktop.theme.enable { - theme = { - fonts = { - gui = { + name = lib.mkOption { + type = with lib.types; either (listOf str) str; + description = "Theme name"; + }; + }; + }; +in +{ + options.home-manager.desktop.theme = { + enable = lib.mkEnableOption "theme config" // { + default = config.home-manager.desktop.enable; + }; + fonts = { + gui = lib.mkOption { + type = lib.types.nullOr themeType; + description = "GUI main font"; + default = { package = pkgs.roboto; name = "Roboto"; }; - icons = { + }; + + icons = lib.mkOption { + type = lib.types.nullOr themeType; + description = "Icons main font"; + default = { package = pkgs.font-awesome_6; name = [ "Font Awesome 6 Brands" @@ -20,18 +41,43 @@ ]; }; }; - colors = with builtins; fromJSON (readFile ./colors.json); - wallpaper.path = lib.mkDefault pkgs.wallpapers.hatsune-miku_walking-4k; + + dpi = lib.mkOption { + type = lib.types.int; + description = "Font dpi"; + default = 135; + }; + }; + + colors = lib.mkOption { + type = with lib.types; attrsOf str; + description = "Base16 colors"; + default = lib.importJSON ./colors.json; + }; + + wallpaper = { + path = lib.mkOption { + type = lib.types.path; + description = "Wallpaper path"; + default = pkgs.wallpapers.hatsune-miku_walking-4k; + }; + scale = lib.mkOption { + type = lib.types.enum [ "tile" "center" "fill" "scale" ]; + default = "fill"; + description = "Wallpaper scaling"; + }; }; + }; + config = lib.mkIf config.home-manager.desktop.theme.enable { # Enable fonts in home.packages to be available to applications fonts.fontconfig.enable = true; home = { - packages = with pkgs; [ - config.theme.fonts.gui.package - config.theme.fonts.icons.package + packages = with pkgs; with config.home-manager.desktop.theme; [ dejavu_fonts + fonts.gui.package + fonts.icons.package gnome.gnome-themes-extra hack-font hicolor-icon-theme diff --git a/home-manager/desktop/xterm.nix b/home-manager/desktop/xterm.nix index e2c81ddf..e678d776 100644 --- a/home-manager/desktop/xterm.nix +++ b/home-manager/desktop/xterm.nix @@ -8,7 +8,7 @@ config = lib.mkIf config.home-manager.desktop.xterm.enable { home.packages = with pkgs; [ hack-font xterm ]; - xresources.extraConfig = with config.theme.colors; '' + xresources.extraConfig = with config.home-manager.desktop.theme.colors; '' #define base00 ${base00} #define base01 ${base01} #define base02 ${base02} diff --git a/hosts/hachune-nixos/default.nix b/hosts/hachune-nixos/default.nix index 7ba57da5..bf60714b 100644 --- a/hosts/hachune-nixos/default.nix +++ b/hosts/hachune-nixos/default.nix @@ -50,7 +50,8 @@ in networking.hostName = "hachune-nixos"; # Use ultrawide wallpaper - home-manager.users.${config.mainUser.username}.theme.wallpaper.path = pkgs.wallpapers.hatsune-miku_stylized-ultrawide; + home-manager.users.${config.mainUser.username}.home-manager.desktop.theme.wallpaper.path = + pkgs.wallpapers.hatsune-miku_stylized-ultrawide; time.timeZone = "America/Sao_Paulo"; } diff --git a/hosts/sankyuu-nixos/default.nix b/hosts/sankyuu-nixos/default.nix index ec6e731e..8dccdd32 100644 --- a/hosts/sankyuu-nixos/default.nix +++ b/hosts/sankyuu-nixos/default.nix @@ -43,7 +43,8 @@ in networking.hostName = "sankyuu-nixos"; # Use ultrawide wallpaper - home-manager.users.${config.mainUser.username}.theme.wallpaper.path = pkgs.wallpapers.hatsune-miku_stylized-ultrawide; + home-manager.users.${config.mainUser.username}.home-manager.desktop.theme.wallpaper.path = + pkgs.wallpapers.hatsune-miku_stylized-ultrawide; nixos = { dev.enable = true; diff --git a/modules/default.nix b/modules/default.nix index 1b27db06..bd1b979d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,6 +4,5 @@ imports = [ ./device.nix ./mainUser.nix - ./theme.nix ]; } diff --git a/modules/theme.nix b/modules/theme.nix deleted file mode 100644 index d5bc7938..00000000 --- a/modules/theme.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ lib, ... }: - -with lib; -let - themeType = types.submodule { - options = { - package = mkOption { - type = with types; nullOr package; - description = "Theme package"; - }; - - name = mkOption { - type = with types; either (listOf str) str; - description = "Theme name"; - }; - }; - }; -in -{ - options.theme = { - fonts = { - gui = mkOption { - type = types.nullOr themeType; - description = "GUI main font"; - }; - - icons = mkOption { - type = types.nullOr themeType; - description = "Icons main font"; - }; - - dpi = mkOption { - type = types.int; - description = "Font dpi"; - default = 135; - }; - }; - - colors = mkOption { - type = with types; attrsOf str; - description = "Base16 colors"; - }; - - wallpaper = { - path = mkOption { - type = types.path; - description = "Wallpaper path"; - }; - scale = mkOption { - type = types.enum [ "tile" "center" "fill" "scale" ]; - default = "fill"; - description = "Wallpaper scaling"; - }; - }; - }; -}