Skip to content

Commit

Permalink
fix(home-manager): remove xdg.enable assertions (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo authored May 21, 2024
1 parent 9999d33 commit 1f19ce7
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 47 deletions.
4 changes: 0 additions & 4 deletions modules/home-manager/btop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ in

config = lib.mkIf enable
{
assertions = [
(lib.ctp.assertXdgEnabled "btop")
];

xdg.configFile."btop${themePath}".source = theme;

programs.btop.settings.color_theme = themeFile;
Expand Down
12 changes: 3 additions & 9 deletions modules/home-manager/fcitx5.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
, ...
}:
let
inherit (lib) ctp;
inherit (config.catppuccin) sources;

cfg = config.i18n.inputMethod.fcitx5.catppuccin;
enable = cfg.enable && config.i18n.inputMethod.enabled == "fcitx5";
in
{
options.i18n.inputMethod.fcitx5.catppuccin = ctp.mkCatppuccinOpt "Fcitx5" // {
options.i18n.inputMethod.fcitx5.catppuccin = lib.ctp.mkCatppuccinOpt "Fcitx5" // {
apply = lib.mkOption {
type = lib.types.bool;
default = true;
Expand All @@ -22,19 +20,15 @@ in
};

config = lib.mkIf enable {
assertions = [
(ctp.assertXdgEnabled "Fcitx5")
];

xdg.dataFile."fcitx5/themes/catppuccin-${cfg.flavour}" = {
source = "${sources.fcitx5}/src/catppuccin-${cfg.flavour}";
recursive = true;
};

xdg.configFile."fcitx5/conf/classicui.conf" = lib.mkIf cfg.apply ({
xdg.configFile."fcitx5/conf/classicui.conf" = lib.mkIf cfg.apply {
text = lib.generators.toINIWithGlobalSection { } {
globalSection.Theme = "catppuccin-${cfg.flavour}";
};
});
};
};
}
9 changes: 2 additions & 7 deletions modules/home-manager/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
, ...
}:
let
inherit (lib) ctp mkIf;
inherit (config.catppuccin) sources;
cfg = config.programs.fish.catppuccin;
enable = cfg.enable && config.programs.fish.enable;

themeName = "Catppuccin ${ctp.mkUpper cfg.flavour}";
themeName = "Catppuccin ${lib.ctp.mkUpper cfg.flavour}";
themePath = "/themes/${themeName}.theme";
in
{
options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt "fish";

config = mkIf enable {
assertions = [
(lib.ctp.assertXdgEnabled "fish")
];

config = lib.mkIf enable {
xdg.configFile."fish${themePath}".source = "${sources.fish}${themePath}";

programs.fish.shellInit = ''
Expand Down
10 changes: 3 additions & 7 deletions modules/home-manager/gtk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let
cfg = config.gtk.catppuccin;
enable = cfg.enable && config.gtk.enable;
# "dark" and "light" can be used alongside the regular accents
cursorAccentType = ctp.mergeEnums (ctp.types.accentOption) (lib.types.enum [ "dark" "light" ]);
cursorAccentType = ctp.mergeEnums ctp.types.accentOption (lib.types.enum [ "dark" "light" ]);
in
{
options.gtk.catppuccin =
Expand Down Expand Up @@ -39,10 +39,6 @@ in
};

config = lib.mkIf enable {
assertions = [
(ctp.assertXdgEnabled "gtk")
];

gtk = {
theme =
let
Expand Down Expand Up @@ -87,7 +83,7 @@ in
name = "Papirus-${polarity}";
package = pkgs.catppuccin-papirus-folders.override {
flavor = cfg.icon.flavour;
accent = cfg.icon.accent;
inherit (cfg.icon) accent;
};
};
};
Expand All @@ -112,7 +108,7 @@ in
];
};
"org/gnome/shell/extensions/user-theme" = {
name = config.gtk.theme.name;
inherit (config.gtk.theme) name;
};
"org/gnome/desktop/interface" = {
color-scheme =
Expand Down
4 changes: 0 additions & 4 deletions modules/home-manager/k9s.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ in
config =
lib.mkIf enable
{
assertions = [
(lib.ctp.assertXdgEnabled "k9s")
];

xdg.configFile."k9s${themePath}".source = theme;

programs.k9s.settings.k9s.ui.skin = themeName;
Expand Down
4 changes: 0 additions & 4 deletions modules/home-manager/micro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ in
lib.ctp.mkCatppuccinOpt "micro";

config = lib.mkIf enable {
assertions = [
(lib.ctp.assertXdgEnabled "micro")
];

programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath;

xdg.configFile."micro/colorschemes/${themePath}".source = "${sources.micro}/src/${themePath}";
Expand Down
9 changes: 2 additions & 7 deletions modules/home-manager/yazi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
, ...
}:
let
inherit (lib) ctp;
inherit (config.catppuccin) sources;

cfg = config.programs.yazi.catppuccin;
enable = cfg.enable && config.programs.yazi.enable;
in
{
options.programs.yazi.catppuccin =
ctp.mkCatppuccinOpt "yazi";
lib.ctp.mkCatppuccinOpt "yazi";

config = lib.mkIf enable {
assertions = [
(lib.ctp.assertXdgEnabled "yazi")
];

programs.yazi.theme = lib.importTOML "${sources.yazi}/themes/${cfg.flavour}.toml";
xdg.configFile."yazi/Catppuccin-${cfg.flavour}.tmTheme".source = "${sources.bat}/themes/Catppuccin ${ctp.mkUpper cfg.flavour}.tmTheme";
xdg.configFile."yazi/Catppuccin-${cfg.flavour}.tmTheme".source = "${sources.bat}/themes/Catppuccin ${lib.ctp.mkUpper cfg.flavour}.tmTheme";
};
}
5 changes: 0 additions & 5 deletions modules/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ in
# followed by the local config attrset
mkAccentOpt = ctp.mkBasicOpt "accent" ctp.types.accentOption;

assertXdgEnabled = name: {
assertion = config.xdg.enable;
message = "Option xdg.enable must be enabled to apply Catppuccin theming for ${name}";
};

# a -> a -> a
# see https://nlewo.github.io/nixos-manual-sphinx/development/option-types.xml.html
# by default enums cannot be merged, but they keep their passed value in `functor.payload`.
Expand Down

0 comments on commit 1f19ce7

Please sign in to comment.