diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 39849d5d64c2..bb690cb8a467 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -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) + ## Backward Incompatibilities {#sec-release-25.05-incompatibilities} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3b31c12df77a..4081aa28b140 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/programs/git-worktree-switcher.nix b/nixos/modules/programs/git-worktree-switcher.nix new file mode 100644 index 000000000000..c85ebfbd49cd --- /dev/null +++ b/nixos/modules/programs/git-worktree-switcher.nix @@ -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" + ); + }; +}