nixos/git-worktree-switcher: init git-worktree-switcher

This module sets up shells so that they work with
[git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher)
This commit is contained in:
jiriks74 2024-11-14 12:53:07 +01:00
parent 17121bf620
commit 3318aa52de
No known key found for this signature in database
GPG Key ID: 1D5E30D3DB2264DE
3 changed files with 43 additions and 0 deletions

View File

@ -20,6 +20,8 @@
- [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable).
- [git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher), switch between git worktrees with speed. Available as [programs.git-worktree-switcher](#opt-programs.git-worktree-switcher.enable)
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
## Backward Incompatibilities {#sec-release-25.05-incompatibilities}

View File

@ -205,6 +205,7 @@
./programs/gdk-pixbuf.nix
./programs/geary.nix
./programs/git.nix
./programs/git-worktree-switcher.nix
./programs/gnome-disks.nix
./programs/gnome-terminal.nix
./programs/gnupg.nix

View File

@ -0,0 +1,40 @@
{
config,
pkgs,
lib,
...
}:
let
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
{
options = {
programs.git-worktree-switcher = {
enable = lib.mkEnableOption "git-worktree-switcher, switch between git worktrees with speed.";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ git-worktree-switcher ];
programs.bash.interactiveShellInit = initScript "bash";
programs.zsh.interactiveShellInit = lib.optionalString config.programs.zsh.enable (
initScript "zsh"
);
programs.fish.interactiveShellInit = lib.optionalString config.programs.fish.enable (
initScript "fish"
);
};
}