Add netty worktree helpers

Add netty-specific worktree helper commands and a zsh wrapper that creates sibling worktrees and cds into them.

Also split script packaging so Darwin keeps the existing wt integration while netty gets git-worktree-based helpers.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Harivansh Rathi 2026-03-30 16:37:46 +00:00
parent 2a79a099c1
commit 8ad1784a82
7 changed files with 172 additions and 74 deletions

23
home/netty-worktree.nix Normal file
View file

@ -0,0 +1,23 @@
{
config,
lib,
pkgs,
...
}: let
customScripts = import ../scripts {inherit config lib pkgs;};
in {
home.packages = builtins.attrValues customScripts.nettyPackages;
programs.zsh.initContent = lib.mkAfter ''
wtc() {
if [[ $# -ne 1 ]]; then
printf 'usage: wtc <worktree-name>\n' >&2
return 1
fi
local worktree_path
worktree_path=$(command wt-create "$1") || return
cd -- "$worktree_path" || return
}
'';
}

View file

@ -1,6 +1,6 @@
{ ... }:
{
{...}: {
imports = [
./common.nix
./netty-worktree.nix
];
}

View file

@ -3,14 +3,14 @@
lib,
pkgs,
...
}:
let
customScripts = import ../scripts { inherit config lib pkgs; };
in
{
home.packages = builtins.attrValues customScripts.packages;
}: let
customScripts = import ../scripts {inherit config lib pkgs;};
in {
home.packages =
builtins.attrValues customScripts.commonPackages
++ lib.optionals pkgs.stdenv.isDarwin (builtins.attrValues customScripts.darwinPackages);
home.activation.initializeThemeState = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
home.activation.initializeThemeState = lib.hm.dag.entryAfter ["writeBoundary"] ''
mkdir -p "${customScripts.theme.paths.stateDir}" "${customScripts.theme.paths.fzfDir}" "${customScripts.theme.paths.ghosttyDir}" "${customScripts.theme.paths.tmuxDir}"
if [[ -f "${customScripts.theme.paths.stateFile}" ]]; then

View file

@ -3,15 +3,14 @@
lib,
pkgs,
...
}:
{
}: {
home.file.".oh-my-zsh/custom/themes/agnoster.zsh-theme".source = ../config/agnoster.zsh-theme;
home.activation.ensureOhMyZshCache = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
home.activation.ensureOhMyZshCache = lib.hm.dag.entryAfter ["writeBoundary"] ''
mkdir -p "${config.xdg.cacheHome}/oh-my-zsh"
'';
home.packages = [ pkgs.oh-my-zsh ];
home.packages = [pkgs.oh-my-zsh];
programs.zsh = {
enable = true;
@ -22,40 +21,42 @@
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
co = "codex --dangerously-bypass-approvals-and-sandbox";
ca = "cursor-agent";
cc = "claude";
ch = "claude-handoff";
cl = "clear";
gc = "git commit";
gd = "git diff";
gk = "git checkout";
gp = "git push";
gpo = "git pull origin";
gs = "git status";
ld = "lumen diff";
lg = "lazygit";
nim = "nvim .";
}
// lib.optionalAttrs pkgs.stdenv.isDarwin {
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
};
shellAliases =
{
co = "codex --dangerously-bypass-approvals-and-sandbox";
ca = "cursor-agent";
cc = "claude";
ch = "claude-handoff";
cl = "clear";
gc = "git commit";
gd = "git diff";
gk = "git checkout";
gp = "git push";
gpo = "git pull origin";
gs = "git status";
ld = "lumen diff";
lg = "lazygit";
nim = "nvim .";
}
// lib.optionalAttrs pkgs.stdenv.isDarwin {
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
};
envExtra = ''
if [[ -f "$HOME/.cargo/env" ]]; then
. "$HOME/.cargo/env"
fi
export NODE_NO_WARNINGS=1
''
+ lib.optionalString pkgs.stdenv.isDarwin ''
# Ghostty shell integration expects a resource directory; the Nix app
# bundle lives in the store instead of /Applications.
export GHOSTTY_RESOURCES_DIR="${pkgs.ghostty-bin}/Applications/Ghostty.app/Contents/Resources/ghostty"
''
+ ''
export MANPAGER="nvim +Man!"
'';
envExtra =
''
if [[ -f "$HOME/.cargo/env" ]]; then
. "$HOME/.cargo/env"
fi
export NODE_NO_WARNINGS=1
''
+ lib.optionalString pkgs.stdenv.isDarwin ''
# Ghostty shell integration expects a resource directory; the Nix app
# bundle lives in the store instead of /Applications.
export GHOSTTY_RESOURCES_DIR="${pkgs.ghostty-bin}/Applications/Ghostty.app/Contents/Resources/ghostty"
''
+ ''
export MANPAGER="nvim +Man!"
'';
initContent = lib.mkMerge [
(lib.mkOrder 550 ''
@ -86,7 +87,9 @@
export BUN_INSTALL="$HOME/.bun"
export PNPM_HOME="${
if pkgs.stdenv.isDarwin then "$HOME/Library/pnpm" else "${config.xdg.dataHome}/pnpm"
if pkgs.stdenv.isDarwin
then "$HOME/Library/pnpm"
else "${config.xdg.dataHome}/pnpm"
}"
bindkey -v
typeset -U path PATH
@ -103,9 +106,9 @@
"/run/current-system/sw/bin"
"/nix/var/nix/profiles/default/bin"
${lib.optionalString pkgs.stdenv.isDarwin ''
"/opt/homebrew/bin"
"/opt/homebrew/sbin"
''}
"/opt/homebrew/bin"
"/opt/homebrew/sbin"
''}
$path
)
@ -249,15 +252,17 @@
_codex_apply_highlight_styles
if command -v wt >/dev/null 2>&1; then
eval "$(command wt config shell init zsh)"
${lib.optionalString pkgs.stdenv.isDarwin ''
if command -v wt >/dev/null 2>&1; then
eval "$(command wt config shell init zsh)"
# `wt` changes directories by sourcing directives into the current shell,
# so wrappers around it must stay shell functions instead of scripts.
wtc() {
wt switch --create --base @ "$@"
}
fi
# `wt` changes directories by sourcing directives into the current shell,
# so wrappers around it must stay shell functions instead of scripts.
wtc() {
wt switch --create --base @ "$@"
}
fi
''}
'')
(lib.mkAfter ''