Conditionally Import Configurations with Home-Manager

I’m creating a beginner-friendly configuration and I want it to be as easy to set up as possible.

It would be nice to have specific categories, like development, games, browsers, etc. that I could
enable/disable making it a lot easier to configure. An example code that I’ve tried was this, however infinite recursion errors happened:

  • (Do note that this is pseudocode)
# Filename: modules/home/home.nix
imports = [./development];
options.enableCategories = lib.mkOption {
    type = lib.types.attrsOf lib.types.bool;
    default = {
      communication = false;
      development   = false;
      other         = false;
    };
    description = "App groups for mass enabling and disabling";
  };
# Filename: modules/home/development/default.nix
lib.mkIf config.enableCategories.development {
  imports = [...];
}

However, I’d like another disabledPackages variable for specific programs/packages to be disabled when a group is enabled.

disabledPackages = with pkgs; [neovim];
 # Filters all disabled packages from all packages
lib.filter (pkg: !(lib.elem pkg config.disabledPackages)) allPackages;

Some other ideas I had about this was using homeManagerModules like in the nix-starter-config repo, but I don’t think I could import variables for user-specific stuff (like git username), and package groups would be difficult even without the aforementioned disabled packages feature

My current way of groups is just importing the groups directly, and for disabling packages it’ll be another parameter passed to the module which will then disable the packages.

imports = [
  (import ../../modules/home/communication)
  (import ../../modules/home/development { inherit user nickname email lib; })
];

Before I implement any of these conditional imports, I’d like to hear your thoughts. Am I missing a super simple feature that would fix all of this? Am I on the right track? Am I overthinking it? I’ll provide more info as needed.

Repo: