Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat: add Nix Home Manager module (#1287)

jan Lemata966651385a5b
diff --git a/flake.nix b/flake.nix
index 3b74c3ff2..b3ee0732c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -181,5 +181,20 @@
'';
};
}
- );
+ )
+ // {
+ homeModules = {
+ default =
+ {
+ lib,
+ config,
+ pkgs,
+ ...
+ }:
+ (import ./nix/home-manager-module.nix) {
+ inherit lib config pkgs;
+ worktrunk-pkgs = self.packages.${pkgs.system};
+ };
+ };
+ };
}
diff --git a/nix/home-manager-module.nix b/nix/home-manager-module.nix
new file mode 100644
index 000000000..0cea31375
--- /dev/null
+++ b/nix/home-manager-module.nix
@@ -0,0 +1,66 @@
+{
+ lib,
+ config,
+ pkgs,
+ worktrunk-pkgs,
+ ...
+}:
+
+let
+ cfg = config.programs.worktrunk;
+in
+{
+ options.programs.worktrunk = {
+ enable = lib.mkEnableOption "worktrunk - Git worktree management CLI";
+
+ package = lib.mkOption {
+ type = lib.types.package;
+ default = worktrunk-pkgs.worktrunk;
+ defaultText = lib.literalExpression "inputs.worktrunk.packages.\${system}.worktrunk";
+ example = lib.literalExpression "inputs.worktrunk.packages.\${system}.worktrunk-with-git-wt";
+ description = ''
+ The worktrunk package to use.
+
+ Use `inputs.worktrunk.packages.''${pkgs.system}.worktrunk-with-git-wt` to install as git-wt
+ so `git wt <command>` works as a git subcommand. Primarily useful on Windows
+ where `wt` conflicts with Windows Terminal.
+ '';
+ };
+
+ enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
+
+ enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
+
+ enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
+
+ enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
+ };
+
+ config = lib.mkIf cfg.enable {
+ home.packages = [ cfg.package ];
+
+ programs = {
+ bash.initExtra = lib.mkIf cfg.enableBashIntegration ''
+ eval "$(${lib.getExe cfg.package} config shell init bash)"
+ '';
+
+ zsh.initContent = lib.mkIf cfg.enableZshIntegration ''
+ eval "$(${lib.getExe cfg.package} config shell init zsh)"
+ '';
+
+ fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
+ ${lib.getExe cfg.package} config shell init fish | source
+ '';
+
+ nushell = lib.mkIf cfg.enableNushellIntegration {
+ extraConfig = ''
+ use ${
+ pkgs.runCommand "worktrunk-nushell-config.nu" { } ''
+ ${lib.getExe cfg.package} config shell init nu > $out
+ ''
+ }
+ '';
+ };
+ };
+ };
+}