name: add-package
description: |
Add a package to this Home Manager dotfiles repo. Use when the user asks
to install, add, or migrate a package — examples "add jq", "ripgrep を入れて",
"lazygit 入れたい", "brew install foo を Nix に移したい", "uv を Nix で",
"kubectl 追加して". The skill picks the right module under home/, checks
nixpkgs and programs.<X> availability, edits the Nix file, validates
with home-manager build, applies via home-manager switch, and verifies
the binary resolves through Nix.
add-package
Add a package to the Home Manager dotfiles config in the right place.
Repo module layout
home/default.nix— sessionVariables,programs.nh, ghostty link, base nix settingshome/fish.nix— fish + atuin/direnv/zoxide/mise/carapace integrationshome/git.nix— git/delta/gh/lazygit + ghq + power_pullhome/neovim.nix—programs.neovim+nvim/symlinkhome/packages.nix—programs.bat+ generalhome.packages
Non-nixpkgs sources (3 fish plugins) live as flake inputs in flake.nix.
Decision flow
Identify the package (e.g. "ripgrep" →
pkgs.ripgrep).Check availability:
nix search nixpkgs <name>(ornix-env -qaP <name>) confirms it exists.- GUI app / macOS cask / not in nixpkgs → keep on brew, note why.
Pick the HM home:
- HM has
programs.<X>module (e.g.bat,gh,git,delta,atuin,direnv,zoxide,mise,carapace,lazygit,nh,neovim,fish) → enable the module so config is declarative too. If it integrates with fish, setenableFishIntegration = true. - Else
home.packages.
- HM has
Pick the file:
- Tool integrates with fish (atuin/direnv/zoxide/mise/carapace/...) →
home/fish.nix - Git / GitHub ecosystem →
home/git.nix - Neovim-related →
home/neovim.nix - General CLI →
home/packages.nix - Don't spread
home.packagesacross modules; preferpackages.nixunless the tool'sprograms.<X>block already lives elsewhere (then keep them together).
- Tool integrates with fish (atuin/direnv/zoxide/mise/carapace/...) →
Edit with
Edittool. Keep alphabetical order within each grouped list (matches the existing style;bat eza fd fzf ripgrepetc.).Validate:
home-manager build --flake .#nwiizo. On error, inspect and fix; do not switch on a failed build.Apply:
home-manager switch --flake .#nwiizo.Verify:
type -p <name>resolves to~/.nix-profile/bin/<name>(or, forprograms.<X>, the binary still works and any generated config is in place).If migrating from brew: ask the user before
brew uninstall <name>. Some users want the brew copy as a fallback.
Discover migration candidates
When the user asks what to migrate from brew:
comm -13 \
<(brew list --formula | sort -u) \
<(ls ~/.nix-profile/bin/ | sort -u)
- Skip
brew list --cask(GUI apps stay on brew). - Prefer tools with a
programs.<X>HM module — declarative config wins. - For tools with non-trivial config, check if the HM module exposes
settingsso the existing~/.config/<tool>/...can be translated.
Don't
- Don't add a package twice (e.g. via both
home.packagesandprograms.<X>.enable). - Don't auto-
brew uninstallwithout explicit confirmation. - Don't skip
home-manager buildvalidation. - Don't add packages directly to
home/default.nix— pick a domain module (packages.nix,git.nix, ...). - Don't reformat unrelated parts of the file. After editing, run
nix fmt -- --check ./home/<file>.nixif a format check is needed.