-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66c5d8b
commit 10f961f
Showing
8 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = [ lib.maintainers.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"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)"' | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
git-worktree-switcher-bash = ./bash.nix; | ||
git-worktree-switcher-fish = ./fish.nix; | ||
git-worktree-switcher-zsh = ./zsh.nix; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)"' | ||
''; | ||
} |