Skip to content

Commit

Permalink
feat: add theme module
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Oct 15, 2023
1 parent 4900887 commit 5d11061
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 19 deletions.
1 change: 1 addition & 0 deletions modules/home/apps/zathura/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ in
extraConfig = "include catppuccin-mocha";
};

#TODO: add to the catppuccin package
xdg.configFile."zathura/catppuccin-mocha".source = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/catppuccin/zathura/main/src/catppuccin-mocha";
hash = "sha256-/HXecio3My2eXTpY7JoYiN9mnXsps4PAThDPs4OCsAk=";
Expand Down
2 changes: 0 additions & 2 deletions modules/home/cli-apps/bottom/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ in
programs.bottom = {
enable = true;
package = pkgs.bottom;

settings = builtins.fromTOML (builtins.readFile (pkgs.catppuccin + "/bottom/macchiato.toml"));
};
};
}
4 changes: 1 addition & 3 deletions modules/home/cli-apps/btop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in
settings = {
#* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes.
#* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes"
color_theme = "catppuccin_macchiato";
# color_theme = "catppuccin_macchiato";

#* If the theme set background should be shown, set to false if you want terminal background transparency.
theme_background = true;
Expand Down Expand Up @@ -233,7 +233,5 @@ in
log_level = "WARNING";
};
};

xdg.configFile."btop/themes/catppuccin_macchiato.theme".source = pkgs.catppuccin + "/btop/catppuccin_macchiato.theme";
};
}
14 changes: 0 additions & 14 deletions modules/home/cli-apps/k9s/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ let
inherit (lib.internal) mkBoolOpt;

cfg = config.khanelinix.cli-apps.k9s;

fromYAML = f:
let
jsonFile =
pkgs.runCommand "k9s yaml to attribute set"
{
nativeBuildInputs = [ pkgs.jc ];
} ''
jc --yaml < "${f}" > "$out"
'';
in
builtins.elemAt (builtins.fromJSON (builtins.readFile jsonFile)) 0;
in
{
options.khanelinix.cli-apps.k9s = {
Expand All @@ -31,8 +19,6 @@ in
programs.k9s = {
enable = true;
package = pkgs.k9s;

skin = fromYAML (pkgs.catppuccin + "/k9s/macchiato.yml");
};
};
}
85 changes: 85 additions & 0 deletions modules/home/desktop/theme/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{ config
, lib
, options
, pkgs
, ...
}:
let
inherit (lib) mkIf mkEnableOption mkOption types;
inherit (lib.internal) mkOpt;

cfg = config.khanelinix.desktop.theme;

catppuccinAccents = [ "rosewater" "flamingo" "pink" "mauve" "red" "maroon" "peach" "yellow" "green" "teal" "sky" "sapphire" "blue" "lavender" ];
catppuccinVariants = [ "latte" "frappe" "macchiato" "mocha" ];

fromYAML = f:
let
jsonFile =
pkgs.runCommand "k9s yaml to attribute set"
{
nativeBuildInputs = [ pkgs.jc ];
} ''
jc --yaml < "${f}" > "$out"
'';
in
builtins.elemAt (builtins.fromJSON (builtins.readFile jsonFile)) 0;
in
{
options.khanelinix.desktop.theme = {
enable = mkEnableOption "Enable custom theme use for applications.";
selectedTheme = mkOption {
type = types.submodule {
options = {
name = mkOpt types.str "catppuccin" "The theme to use.";
accent = mkOption {
type = types.enum catppuccinAccents;
default = "blue";
description = ''
An optional theme accent.
'';
};
variant = mkOption {
type = types.enum catppuccinVariants;
default = "macchiato";
description = ''
An optional theme variant.
'';
};
};
};
default = {
name = "catppuccin";
accent = "blue";
variant = "macchiato";
};
description = "Theme to use for applications.";
};
package = mkOption {
type = types.package;
default = (pkgs.catppuccin.override {
accent = cfg.selectedTheme.accent;
variant = cfg.selectedTheme.variant;
});
description = ''
The `spotifyd` package to use.
Can be used to specify extensions.
'';
};
};

config = mkIf cfg.enable {
#bottom
programs.bottom.settings = builtins.fromTOML (builtins.readFile (cfg.package + "/bottom/${cfg.selectedTheme.variant}.toml"));

# btop
programs.btop = {
settings.color_theme = "${cfg.selectedTheme.name}_${cfg.selectedTheme.variant}";
};
xdg.configFile."btop/themes/${cfg.selectedTheme.name}_${cfg.selectedTheme.variant}.theme".source = mkIf config.programs.btop.enable (cfg.package + "/btop/${cfg.selectedTheme.name}_${cfg.selectedTheme.variant}.theme");

# k9s
programs.k9s.skin = fromYAML (cfg.package + "/k9s/${cfg.selectedTheme.variant}.yml");

};
}
2 changes: 2 additions & 0 deletions modules/home/suites/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ in
qt.enable = pkgs.stdenv.isLinux;
wezterm = enabled;
};

theme = enabled;
};

services = {
Expand Down

0 comments on commit 5d11061

Please sign in to comment.