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

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-11-03 18:25:24 +01:00 committed by GitHub
parent 5cb3e83bdd
commit a0e508260c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 15 deletions

View file

@ -17,11 +17,11 @@ in
config = lib.mkIf enable config = lib.mkIf enable
{ {
xdg = { assertions = [
# xdg is required for this to work (lib.ctp.assertXdgEnabled "btop")
enable = lib.mkForce true; ];
configFile."btop${themePath}".source = theme;
}; xdg.configFile."btop${themePath}".source = theme;
programs.btop.settings.color_theme = themeFile; programs.btop.settings.color_theme = themeFile;
}; };

View file

@ -14,13 +14,12 @@ in
{ {
options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt "fish"; options.programs.fish.catppuccin = lib.ctp.mkCatppuccinOpt "fish";
# xdg is required for this to work
config = mkIf enable { config = mkIf enable {
xdg = { assertions = [
enable = lib.mkForce true; (lib.ctp.assertXdgEnabled "fish")
];
configFile."fish${themePath}".source = "${sources.fish}${themePath}"; xdg.configFile."fish${themePath}".source = "${sources.fish}${themePath}";
};
programs.fish.shellInit = '' programs.fish.shellInit = ''
fish_config theme choose "${themeName}" fish_config theme choose "${themeName}"

View file

@ -14,12 +14,12 @@ in
lib.ctp.mkCatppuccinOpt "micro"; lib.ctp.mkCatppuccinOpt "micro";
config = lib.mkIf enable { config = lib.mkIf enable {
assertions = [
(lib.ctp.assertXdgEnabled "micro")
];
programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath; programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath;
xdg = { xdg.configFile."micro/colorschemes/${themePath}".source = "${sources.micro}/src/${themePath}";
# xdg is required for this to work
enable = lib.mkForce true;
configFile."micro/colorschemes/${themePath}".source = "${sources.micro}/src/${themePath}";
};
}; };
} }

View file

@ -105,4 +105,9 @@ in
# the first string should be the name of the module, # the first string should be the name of the module,
# followed by the local config attrset # followed by the local config attrset
mkAccentOpt = mkBasicOpt "accent" types.accentOption; mkAccentOpt = mkBasicOpt "accent" types.accentOption;
assertXdgEnabled = name: {
assertion = config.xdg.enable;
message = "Option xdg.enable must be enabled to apply Catppuccin theming for ${name}";
};
} }

View file

@ -42,6 +42,8 @@ in
inherit (common) catppuccin; inherit (common) catppuccin;
xdg.enable = true;
home = { home = {
username = "test"; username = "test";
stateVersion = lib.mkDefault "23.11"; stateVersion = lib.mkDefault "23.11";