treewide: implement auto importing for modules

Reduce maintenance burden and increase efficiency by automatically
importing modules following a specific convention.

Co-authored-by: awwpotato <awwpotato@voidq.com>
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-06-20 14:39:55 -05:00
parent fefeb0e928
commit 4fca600cb1
461 changed files with 72 additions and 474 deletions

View file

@ -0,0 +1,46 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (lib) mkEnableOption mkPackageOption optionalString;
cfg = config.programs.git-worktree-switcher;
initScript =
shell:
if (shell == "fish") then
''
${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source
''
else
''
eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})"
'';
in
{
meta.maintainers = with lib.maintainers; [
jiriks74
mateusauler
];
options.programs.git-worktree-switcher = {
enable = mkEnableOption "git-worktree-switcher";
package = mkPackageOption pkgs "git-worktree-switcher" { };
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.initExtra = optionalString cfg.enableBashIntegration (initScript "bash");
programs.fish.interactiveShellInit = optionalString cfg.enableFishIntegration (initScript "fish");
programs.zsh.initContent = optionalString cfg.enableZshIntegration (initScript "zsh");
};
}