1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-06 16:57:03 +00:00

git-worktree-switcher: init module

This commit is contained in:
Mateus Auler 2024-12-14 16:13:07 -03:00 committed by Austin Horstman
parent 59fe145f0b
commit 9c8169b446
8 changed files with 121 additions and 1 deletions

View file

@ -2034,7 +2034,17 @@ in {
- programs.zellij.enableZshIntegration
'';
}
{
time = "2025-02-11T15:25:26+00:00";
message = ''
A new module is available: 'programs.git-worktree-switcher'.
git-worktree-switcher allows you to quickly switch git worktrees.
It includes shell completions for Bash, Fish and Zsh.
See https://github.com/mateusauler/git-worktree-switcher for more.
'';
}
];
};
}

View file

@ -110,6 +110,7 @@ let
./programs/ghostty.nix
./programs/git-cliff.nix
./programs/git-credential-oauth.nix
./programs/git-worktree-switcher.nix
./programs/git.nix
./programs/gitui.nix
./programs/gnome-shell.nix

View file

@ -0,0 +1,52 @@
{ pkgs, config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption 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 = mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable git-worktree-switcher's Bash integration.
'';
};
enableFishIntegration = mkOption {
type = lib.types.bool;
default = config.programs.fish.enable;
description = ''
Whether to enable git-worktree-switcher's Fish integration.
'';
};
enableZshIntegration = mkOption {
type = lib.types.bool;
default = config.programs.zsh.enable;
description = ''
Whether to enable git-worktree-switcher's Zsh integration.
'';
};
};
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.initExtra =
optionalString cfg.enableZshIntegration (initScript "zsh");
};
}

View file

@ -157,6 +157,7 @@ in import nmtSrc {
./modules/programs/git
./modules/programs/git-cliff
./modules/programs/git-credential-oauth
./modules/programs/git-worktree-switcher
./modules/programs/go
./modules/programs/gpg
./modules/programs/gradle

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
bash.enable = true;
git-worktree-switcher.enable = true;
};
test.stubs.git-worktree-switcher = { name = "git-worktree-switcher"; };
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileContains \
home-files/.bashrc \
'eval "$(@git-worktree-switcher@/bin/git-worktree-switcher init bash)"'
'';
}

View file

@ -0,0 +1,5 @@
{
git-worktree-switcher-bash = ./bash.nix;
git-worktree-switcher-fish = ./fish.nix;
git-worktree-switcher-zsh = ./zsh.nix;
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
fish.enable = true;
git-worktree-switcher.enable = true;
};
test.stubs.git-worktree-switcher = { name = "git-worktree-switcher"; };
nmt.script = ''
assertFileExists home-files/.config/fish/config.fish
assertFileContains \
home-files/.config/fish/config.fish \
'@git-worktree-switcher@/bin/git-worktree-switcher init fish | source'
'';
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
zsh.enable = true;
git-worktree-switcher.enable = true;
};
test.stubs.git-worktree-switcher = { name = "git-worktree-switcher"; };
nmt.script = ''
assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'eval "$(@git-worktree-switcher@/bin/git-worktree-switcher init zsh)"'
'';
}