mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-07 01:07:00 +00:00
git-worktree-switcher: init module
This commit is contained in:
parent
59fe145f0b
commit
9c8169b446
8 changed files with 121 additions and 1 deletions
|
@ -2034,7 +2034,17 @@ in {
|
||||||
- programs.zellij.enableZshIntegration
|
- 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.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ let
|
||||||
./programs/ghostty.nix
|
./programs/ghostty.nix
|
||||||
./programs/git-cliff.nix
|
./programs/git-cliff.nix
|
||||||
./programs/git-credential-oauth.nix
|
./programs/git-credential-oauth.nix
|
||||||
|
./programs/git-worktree-switcher.nix
|
||||||
./programs/git.nix
|
./programs/git.nix
|
||||||
./programs/gitui.nix
|
./programs/gitui.nix
|
||||||
./programs/gnome-shell.nix
|
./programs/gnome-shell.nix
|
||||||
|
|
52
modules/programs/git-worktree-switcher.nix
Normal file
52
modules/programs/git-worktree-switcher.nix
Normal 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");
|
||||||
|
};
|
||||||
|
}
|
|
@ -157,6 +157,7 @@ in import nmtSrc {
|
||||||
./modules/programs/git
|
./modules/programs/git
|
||||||
./modules/programs/git-cliff
|
./modules/programs/git-cliff
|
||||||
./modules/programs/git-credential-oauth
|
./modules/programs/git-credential-oauth
|
||||||
|
./modules/programs/git-worktree-switcher
|
||||||
./modules/programs/go
|
./modules/programs/go
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/gradle
|
./modules/programs/gradle
|
||||||
|
|
17
tests/modules/programs/git-worktree-switcher/bash.nix
Normal file
17
tests/modules/programs/git-worktree-switcher/bash.nix
Normal 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)"'
|
||||||
|
'';
|
||||||
|
}
|
5
tests/modules/programs/git-worktree-switcher/default.nix
Normal file
5
tests/modules/programs/git-worktree-switcher/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
git-worktree-switcher-bash = ./bash.nix;
|
||||||
|
git-worktree-switcher-fish = ./fish.nix;
|
||||||
|
git-worktree-switcher-zsh = ./zsh.nix;
|
||||||
|
}
|
17
tests/modules/programs/git-worktree-switcher/fish.nix
Normal file
17
tests/modules/programs/git-worktree-switcher/fish.nix
Normal 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'
|
||||||
|
'';
|
||||||
|
}
|
17
tests/modules/programs/git-worktree-switcher/zsh.nix
Normal file
17
tests/modules/programs/git-worktree-switcher/zsh.nix
Normal 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)"'
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue