Skip to content

Commit

Permalink
home-manager/theme: refactor, remove old modules/theme
Browse files Browse the repository at this point in the history
modules/theme were only being used in home-manager/theme anyway, so
instead of having a "shared" module that is not shared anywhere, let's
have it in a place where it makes sense.
  • Loading branch information
thiagokokada committed Oct 16, 2023
1 parent 66c5c39 commit 67abcf3
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 97 deletions.
4 changes: 2 additions & 2 deletions home-manager/desktop/dunst.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
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;
foreground = base05;
};
in
{
global = with config.theme.fonts; {
global = with config.home-manager.desktop.theme.fonts; {
font = "${gui.name} 8";
markup = true;
format = "<b>%s</b>\\n%b";
Expand Down
6 changes: 3 additions & 3 deletions home-manager/desktop/i3/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -49,7 +49,7 @@
};
};
}]
, fonts ? with config.theme.fonts; {
, fonts ? with config.home-manager.desktop.theme.fonts; {
names = lib.flatten [
gui.name
icons.name
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion home-manager/desktop/i3/i3status-rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions home-manager/desktop/i3/rofi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion home-manager/desktop/i3/screen-locker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions home-manager/desktop/i3/wallpaper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand Down
2 changes: 1 addition & 1 deletion home-manager/desktop/i3/x11.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion home-manager/desktop/kitty.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 2 additions & 2 deletions home-manager/desktop/sway/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions home-manager/desktop/sway/fuzzel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions home-manager/desktop/sway/swaylock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion home-manager/desktop/sway/waybar.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
74 changes: 60 additions & 14 deletions home-manager/desktop/theme/default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,83 @@
{ 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"
"Font Awesome 6 Free Solid"
];
};
};
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
Expand Down
2 changes: 1 addition & 1 deletion home-manager/desktop/xterm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion hosts/hachune-nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
3 changes: 2 additions & 1 deletion hosts/sankyuu-nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
imports = [
./device.nix
./mainUser.nix
./theme.nix
];
}
56 changes: 0 additions & 56 deletions modules/theme.nix

This file was deleted.

0 comments on commit 67abcf3

Please sign in to comment.