Skip to content

Commit

Permalink
refactor(home-manager): ensure xdg.enable using assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Sefa Eyeoglu <[email protected]>
  • Loading branch information
Scrumplex committed Nov 3, 2023
1 parent f616c3c commit 2455701
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
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

0 comments on commit 2455701

Please sign in to comment.