chore(modules): use attrset as argument to mkCatppuccinOpt (#252)

This commit is contained in:
seth 2024-06-28 16:29:30 +00:00 committed by GitHub
parent eaab21cb0b
commit 3f4607481b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 68 additions and 57 deletions

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.alacritty.enable;
in
{
options.programs.alacritty.catppuccin = lib.ctp.mkCatppuccinOpt "alacritty";
options.programs.alacritty.catppuccin = lib.ctp.mkCatppuccinOpt { name = "alacritty"; };
config = lib.mkIf enable {
programs.alacritty.settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavor}.toml";

View file

@ -6,7 +6,7 @@ let
themeName = "Catppuccin ${lib.ctp.mkUpper cfg.flavor}";
in
{
options.programs.bat.catppuccin = lib.ctp.mkCatppuccinOpt "bat";
options.programs.bat.catppuccin = lib.ctp.mkCatppuccinOpt { name = "bat"; };
config = lib.mkIf enable {
programs.bat = {

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.bottom.enable;
in
{
options.programs.bottom.catppuccin = lib.ctp.mkCatppuccinOpt "bottom";
options.programs.bottom.catppuccin = lib.ctp.mkCatppuccinOpt { name = "bottom"; };
config = lib.mkIf enable {
programs.bottom = {

View file

@ -9,7 +9,7 @@ let
theme = sources.btop + themePath;
in
{
options.programs.btop.catppuccin = lib.ctp.mkCatppuccinOpt "btop";
options.programs.btop.catppuccin = lib.ctp.mkCatppuccinOpt { name = "btop"; };
config = lib.mkIf enable {
xdg.configFile."btop${themePath}".source = theme;

View file

@ -6,7 +6,7 @@ let
flavor = "${cfg.flavor}" + lib.optionalString cfg.transparent "-transparent";
in
{
options.programs.cava.catppuccin = lib.ctp.mkCatppuccinOpt "cava" // {
options.programs.cava.catppuccin = lib.ctp.mkCatppuccinOpt { name = "cava"; } // {
transparent = lib.mkEnableOption "transparent version of flavor";
};

View file

@ -17,7 +17,7 @@ let
);
in
{
options.catppuccin.pointerCursor = ctp.mkCatppuccinOpt "cursors" // {
options.catppuccin.pointerCursor = ctp.mkCatppuccinOpt { name = "pointer cursors"; } // {
accent = ctp.mkBasicOpt "accent" cursorAccentType "cursors";
};

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.git.delta.enable;
in
{
options.programs.git.delta.catppuccin = lib.ctp.mkCatppuccinOpt "catppuccin";
options.programs.git.delta.catppuccin = lib.ctp.mkCatppuccinOpt { name = "delta"; };
config = lib.mkIf enable {
programs.git = {

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.services.dunst.enable;
in
{
options.services.dunst.catppuccin = lib.ctp.mkCatppuccinOpt "dunst";
options.services.dunst.catppuccin = lib.ctp.mkCatppuccinOpt { name = "dunst"; };
config.services.dunst = lib.mkIf enable {
settings = lib.ctp.fromINI (sources.dunst + "/themes/${cfg.flavor}.conf");

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.i18n.inputMethod.enabled == "fcitx5";
in
{
options.i18n.inputMethod.fcitx5.catppuccin = lib.ctp.mkCatppuccinOpt "Fcitx5" // {
options.i18n.inputMethod.fcitx5.catppuccin = lib.ctp.mkCatppuccinOpt { name = "Fcitx5"; } // {
apply = lib.mkOption {
type = lib.types.bool;
default = true;

View file

@ -8,7 +8,7 @@ let
themePath = "/themes/${themeName}.theme";
in
{
options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt "fish";
options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt { name = "fish"; };
config = lib.mkIf enable {
xdg.configFile."fish${themePath}".source = "${sources.fish}${themePath}";

View file

@ -7,7 +7,7 @@ let
theme = lib.ctp.fromINI (sources.foot + "/themes/catppuccin-${cfg.flavor}.ini");
in
{
options.programs.foot.catppuccin = lib.ctp.mkCatppuccinOpt "foot";
options.programs.foot.catppuccin = lib.ctp.mkCatppuccinOpt { name = "foot"; };
config.programs.foot = lib.mkIf enable { settings = theme; };
}

View file

@ -7,7 +7,7 @@ let
palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavor}.colors;
in
{
options.programs.fzf.catppuccin = lib.ctp.mkCatppuccinOpt "fzf";
options.programs.fzf.catppuccin = lib.ctp.mkCatppuccinOpt { name = "fzf"; };
config.programs.fzf.colors =
lib.mkIf enable

View file

@ -6,7 +6,7 @@ let
theme = "${sources.gh-dash}/themes/${cfg.flavor}/catppuccin-${cfg.flavor}-${cfg.accent}.yml";
in
{
options.programs.gh-dash.catppuccin = lib.ctp.mkCatppuccinOpt "gh-dash" // {
options.programs.gh-dash.catppuccin = lib.ctp.mkCatppuccinOpt { name = "gh-dash"; } // {
accent = lib.ctp.mkAccentOpt "gh-dash";
};

View file

@ -6,7 +6,7 @@ let
enable = cfg.enable && config.programs.gitui.enable;
in
{
options.programs.gitui.catppuccin = lib.ctp.mkCatppuccinOpt "gitui";
options.programs.gitui.catppuccin = lib.ctp.mkCatppuccinOpt { name = "gitui"; };
config = lib.mkIf enable {
programs.gitui.theme = builtins.path {

View file

@ -5,7 +5,7 @@ let
inherit (cfg) enable;
in
{
options.programs.glamour.catppuccin = lib.ctp.mkCatppuccinOpt "glamour";
options.programs.glamour.catppuccin = lib.ctp.mkCatppuccinOpt { name = "glamour"; };
config = {
home.sessionVariables = lib.mkIf enable {

View file

@ -19,7 +19,7 @@ let
enable = cfg.enable && config.gtk.enable;
in
{
options.gtk.catppuccin = ctp.mkCatppuccinOpt "gtk" // {
options.gtk.catppuccin = ctp.mkCatppuccinOpt { name = "gtk"; } // {
# NOTE: we are overriding the previous declaration of `enable` here
# as this module is deprecated and we do not want it to apply with
# the global `catppuccin.enable`
@ -48,8 +48,8 @@ in
gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
icon = ctp.mkCatppuccinOpt "gtk modified Papirus icon theme" // {
accent = ctp.mkAccentOpt "gtk modified Papirus icon theme";
icon = ctp.mkCatppuccinOpt { name = "GTK modified Papirus icon theme"; } // {
accent = ctp.mkAccentOpt "GTK modified Papirus icon theme";
};
};

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.helix.enable;
in
{
options.programs.helix.catppuccin = lib.ctp.mkCatppuccinOpt "helix" // {
options.programs.helix.catppuccin = lib.ctp.mkCatppuccinOpt { name = "helix"; } // {
useItalics = lib.mkEnableOption "Italics in Catppuccin theme for Helix";
};

View file

@ -6,9 +6,11 @@ let
inherit (config.catppuccin) pointerCursor;
in
{
options.wayland.windowManager.hyprland.catppuccin = lib.ctp.mkCatppuccinOpt "hyprland" // {
accent = lib.ctp.mkAccentOpt "hyprland";
};
options.wayland.windowManager.hyprland.catppuccin =
lib.ctp.mkCatppuccinOpt { name = "hyprland"; }
// {
accent = lib.ctp.mkAccentOpt "hyprland";
};
config = lib.mkIf enable {
home.sessionVariables = lib.mkIf pointerCursor.enable {

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.imv.enable;
in
{
options.programs.imv.catppuccin = lib.ctp.mkCatppuccinOpt "imv";
options.programs.imv.catppuccin = lib.ctp.mkCatppuccinOpt { name = "imv"; };
config.programs.imv.settings = lib.mkIf enable (
lib.ctp.fromINI (sources.imv + "/themes/${cfg.flavor}.config")

View file

@ -11,7 +11,7 @@ let
theme = sources.k9s + "/dist/${themeFile}";
in
{
options.programs.k9s.catppuccin = lib.ctp.mkCatppuccinOpt "k9s" // {
options.programs.k9s.catppuccin = lib.ctp.mkCatppuccinOpt { name = "k9s"; } // {
transparent = lib.mkEnableOption "transparent version of flavor";
};

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.kitty.enable;
in
{
options.programs.kitty.catppuccin = ctp.mkCatppuccinOpt "kitty";
options.programs.kitty.catppuccin = ctp.mkCatppuccinOpt { name = "kitty"; };
config.programs.kitty = lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavor}"; };
}

View file

@ -17,7 +17,7 @@ let
themeName = "Catppuccin-${flavorCapitalized}-${accentCapitalized}";
in
{
options.qt.style.catppuccin = lib.ctp.mkCatppuccinOpt "Kvantum" // {
options.qt.style.catppuccin = lib.ctp.mkCatppuccinOpt { name = "Kvantum"; } // {
accent = lib.ctp.mkAccentOpt "Kvantum";
apply = lib.mkOption {

View file

@ -8,7 +8,7 @@ let
themePath = "${cfg.flavor}/${cfg.accent}.yml";
in
{
options.programs.lazygit.catppuccin = lib.ctp.mkCatppuccinOpt "lazygit" // {
options.programs.lazygit.catppuccin = lib.ctp.mkCatppuccinOpt { name = "lazygit"; } // {
accent = ctp.mkAccentOpt "lazygit";
};

View file

@ -14,7 +14,7 @@ let
extraConfigAttrs = lib.attrsets.getAttrs [ "urgency=high" ] theme;
in
{
options.services.mako.catppuccin = lib.ctp.mkCatppuccinOpt "mako";
options.services.mako.catppuccin = lib.ctp.mkCatppuccinOpt { name = "mako"; };
# Will cause infinite recursion if config.services.mako is directly set as a whole
config.services.mako = lib.mkIf enable {

View file

@ -7,7 +7,7 @@ let
themePath = "catppuccin-${cfg.flavor}.micro";
in
{
options.programs.micro.catppuccin = lib.ctp.mkCatppuccinOpt "micro";
options.programs.micro.catppuccin = lib.ctp.mkCatppuccinOpt { name = "micro"; };
config = lib.mkIf enable {
programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath;

View file

@ -6,7 +6,7 @@ let
themeDir = sources.mpv + "/themes/${cfg.flavor}/${cfg.accent}";
in
{
options.programs.mpv.catppuccin = lib.ctp.mkCatppuccinOpt "mpv" // {
options.programs.mpv.catppuccin = lib.ctp.mkCatppuccinOpt { name = "mpv"; } // {
accent = lib.ctp.mkAccentOpt "mpv";
};

View file

@ -9,7 +9,7 @@ let
enable = cfg.enable && config.programs.neovim.enable;
in
{
options.programs.neovim.catppuccin = lib.ctp.mkCatppuccinOpt "neovim";
options.programs.neovim.catppuccin = lib.ctp.mkCatppuccinOpt { name = "neovim"; };
config.programs.neovim = lib.mkIf enable {
plugins = with pkgs.vimPlugins; [

View file

@ -7,7 +7,7 @@ let
theme = if cfg.flavor == "latte" then "latte" else "dark";
in
{
options.programs.newsboat.catppuccin = lib.ctp.mkCatppuccinOpt "newsboat";
options.programs.newsboat.catppuccin = lib.ctp.mkCatppuccinOpt { name = "newsboat"; };
config = lib.mkIf enable {
programs.newsboat.extraConfig = builtins.readFile "${sources.newsboat}/themes/${theme}";

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.services.polybar.enable;
in
{
options.services.polybar.catppuccin = lib.ctp.mkCatppuccinOpt "polybar";
options.services.polybar.catppuccin = lib.ctp.mkCatppuccinOpt { name = "polybar"; };
config.services.polybar.extraConfig = lib.mkIf enable (
builtins.readFile "${sources.polybar}/themes/${cfg.flavor}.ini"

View file

@ -7,7 +7,7 @@ let
enable = cfg.enable && config.programs.rio.enable;
in
{
options.programs.rio.catppuccin = ctp.mkCatppuccinOpt "rio";
options.programs.rio.catppuccin = ctp.mkCatppuccinOpt { name = "rio"; };
config = lib.mkIf enable {
programs.rio.settings = lib.importTOML "${sources.rio}/themes/catppuccin-${cfg.flavor}.toml";

View file

@ -6,7 +6,7 @@ let
enable = cfg.enable && config.programs.rofi.enable;
in
{
options.programs.rofi.catppuccin = lib.ctp.mkCatppuccinOpt "rofi";
options.programs.rofi.catppuccin = lib.ctp.mkCatppuccinOpt { name = "rofi"; };
config.programs.rofi = lib.mkIf enable {
theme = {

View file

@ -6,7 +6,7 @@ let
palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavor}.colors;
in
{
options.programs.skim.catppuccin = lib.ctp.mkCatppuccinOpt "skim";
options.programs.skim.catppuccin = lib.ctp.mkCatppuccinOpt { name = "skim"; };
config.programs.skim = lib.mkIf enable {
defaultOptions = [

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.starship.enable;
in
{
options.programs.starship.catppuccin = lib.ctp.mkCatppuccinOpt "starship";
options.programs.starship.catppuccin = lib.ctp.mkCatppuccinOpt { name = "starship"; };
config.programs.starship.settings = lib.mkIf enable (
{

View file

@ -6,7 +6,7 @@ let
theme = "${sources.sway}/themes/catppuccin-${cfg.flavor}";
in
{
options.wayland.windowManager.sway.catppuccin = lib.ctp.mkCatppuccinOpt "sway";
options.wayland.windowManager.sway.catppuccin = lib.ctp.mkCatppuccinOpt { name = "sway"; };
config = lib.mkIf enable {
wayland.windowManager.sway.extraConfigEarly = ''

View file

@ -24,7 +24,7 @@ let
};
in
{
options.programs.tmux.catppuccin = ctp.mkCatppuccinOpt "tmux" // {
options.programs.tmux.catppuccin = ctp.mkCatppuccinOpt { name = "tmux"; } // {
extraConfig = mkOption {
type = types.lines;
description = "Additional configuration for the catppuccin plugin.";

View file

@ -5,7 +5,7 @@ let
enable = cfg.enable && config.programs.tofi.enable;
in
{
options.programs.tofi.catppuccin = lib.ctp.mkCatppuccinOpt "tofi";
options.programs.tofi.catppuccin = lib.ctp.mkCatppuccinOpt { name = "tofi"; };
config.programs.tofi = lib.mkIf enable {
settings = lib.ctp.fromINI (sources.tofi + "/themes/catppuccin-${cfg.flavor}");

View file

@ -6,7 +6,7 @@ let
styleFile = "${sources.waybar}/themes/${cfg.flavor}.css";
in
{
options.programs.waybar.catppuccin = (lib.ctp.mkCatppuccinOpt "waybar") // {
options.programs.waybar.catppuccin = lib.ctp.mkCatppuccinOpt { name = "waybar"; } // {
mode = lib.mkOption {
type = lib.types.enum [
"prependImport"

View file

@ -6,7 +6,7 @@ let
enable = cfg.enable && config.programs.yazi.enable;
in
{
options.programs.yazi.catppuccin = lib.ctp.mkCatppuccinOpt "yazi";
options.programs.yazi.catppuccin = lib.ctp.mkCatppuccinOpt { name = "yazi"; };
config = lib.mkIf enable {
programs.yazi.theme = lib.importTOML "${sources.yazi}/themes/${cfg.flavor}.toml";

View file

@ -11,7 +11,7 @@ let
themeFile = sources.zathura + "/src/catppuccin-${cfg.flavor}";
in
{
options.programs.zathura.catppuccin = lib.ctp.mkCatppuccinOpt "zathura";
options.programs.zathura.catppuccin = lib.ctp.mkCatppuccinOpt { name = "zathura"; };
config.programs.zathura.options = lib.mkIf enable (
lib.ctp.fromINI (

View file

@ -5,7 +5,7 @@ let
themeName = "catppuccin-${cfg.flavor}";
in
{
options.programs.zellij.catppuccin = lib.ctp.mkCatppuccinOpt "zellij";
options.programs.zellij.catppuccin = lib.ctp.mkCatppuccinOpt { name = "zellij"; };
config = lib.mkIf enable {
programs.zellij.settings = {

View file

@ -6,7 +6,9 @@ let
enable = cfg.enable && config.programs.zsh.syntaxHighlighting.enable;
in
{
options.programs.zsh.syntaxHighlighting.catppuccin = ctp.mkCatppuccinOpt "zsh syntax highlighting";
options.programs.zsh.syntaxHighlighting.catppuccin = ctp.mkCatppuccinOpt {
name = "Zsh Syntax Highlighting";
};
config.programs.zsh = lib.mkIf enable {
initExtra = lib.mkBefore ''

View file

@ -107,15 +107,22 @@ in
# string -> a
# this creates a basic attrset only containing an
# enable and flavor option. the fist string should
# be the name of the module, followed by the local config
# attrset
mkCatppuccinOpt = name: {
enable = lib.mkEnableOption "Catppuccin theme" // {
default = config.catppuccin.enable;
# enable and flavor option. `name` should be the name
# of the module, while `enableDefault` is a boolean
# representing the default of the created `enable`
# option
mkCatppuccinOpt =
{
name,
enableDefault ? config.catppuccin.enable,
}:
{
enable = lib.mkEnableOption "Catppuccin theme for ${name}" // {
default = enableDefault;
};
flavor = ctp.mkFlavorOpt name;
};
flavor = ctp.mkFlavorOpt name;
};
# string -> a
# this creates an accent option for modules

View file

@ -6,7 +6,7 @@ let
palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavor}.colors;
in
{
options.console.catppuccin = lib.ctp.mkCatppuccinOpt "console";
options.console.catppuccin = lib.ctp.mkCatppuccinOpt { name = "console"; };
config.console.colors = lib.mkIf enable (
# Manually populate with colors from catppuccin/tty

View file

@ -16,7 +16,7 @@ let
'';
in
{
options.boot.loader.grub.catppuccin = lib.ctp.mkCatppuccinOpt "grub";
options.boot.loader.grub.catppuccin = lib.ctp.mkCatppuccinOpt { name = "grub"; };
config.boot.loader.grub = lib.mkIf enable {
font = "${theme}/font.pf2";

View file

@ -10,7 +10,7 @@ let
enable = cfg.enable && config.boot.plymouth.enable;
in
{
options.boot.plymouth.catppuccin = ctp.mkCatppuccinOpt "plymouth";
options.boot.plymouth.catppuccin = ctp.mkCatppuccinOpt { name = "plymouth"; };
config.boot.plymouth = mkIf enable {
theme = "catppuccin-${cfg.flavor}";

View file

@ -16,7 +16,7 @@ let
in
{
options.services.displayManager.sddm.catppuccin = ctp.mkCatppuccinOpt "sddm" // {
options.services.displayManager.sddm.catppuccin = ctp.mkCatppuccinOpt { name = "sddm"; } // {
font = mkOption {
type = types.str;
default = "Noto Sans";