Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(home-manager): ensure xdg.enable using assertion #59

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/home-manager/btop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ in

config = lib.mkIf enable
{
xdg = {
# xdg is required for this to work
enable = lib.mkForce true;
configFile."btop${themePath}".source = theme;
};
assertions = [
(lib.ctp.assertXdgEnabled "btop")
];

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

programs.btop.settings.color_theme = themeFile;
};
Expand Down
9 changes: 4 additions & 5 deletions modules/home-manager/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ in
{
options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt "fish";

# xdg is required for this to work
config = mkIf enable {
xdg = {
enable = lib.mkForce true;
assertions = [
(lib.ctp.assertXdgEnabled "fish")
];

configFile."fish${themePath}".source = "${sources.fish}${themePath}";
};
xdg.configFile."fish${themePath}".source = "${sources.fish}${themePath}";

programs.fish.shellInit = ''
fish_config theme choose "${themeName}"
Expand Down
10 changes: 5 additions & 5 deletions modules/home-manager/micro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ in
lib.ctp.mkCatppuccinOpt "micro";

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

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

xdg = {
# xdg is required for this to work
enable = lib.mkForce true;
configFile."micro/colorschemes/${themePath}".source = "${sources.micro}/src/${themePath}";
};
xdg.configFile."micro/colorschemes/${themePath}".source = "${sources.micro}/src/${themePath}";
};
}
5 changes: 5 additions & 0 deletions modules/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ in
# the first string should be the name of the module,
# followed by the local config attrset
mkAccentOpt = mkBasicOpt "accent" types.accentOption;

assertXdgEnabled = name: {
assertion = config.xdg.enable;
message = "Option xdg.enable must be enabled to apply Catppuccin theming for ${name}";
};
}
2 changes: 2 additions & 0 deletions test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ in

inherit (common) catppuccin;

xdg.enable = true;

home = {
username = "test";
stateVersion = lib.mkDefault "23.11";
Expand Down