Agent skill
nix-shell
Search Nix packages and run commands with packages from nixpkgs that are not installed locally. Use when you need a package not available locally or want to search nixpkgs.
Install this agent skill to your Project
npx add-skill https://github.com/geggo98/dotfiles/tree/main/modules/ai/_files/skills/nix-shell
SKILL.md
Nix Shell Skill
1. Purpose
Use this skill to search for Nix packages and run commands using tools that are not installed locally.
It wraps nix search, nix-locate, and nix shell to give the agent on-demand access to any package in nixpkgs.
2. Usage Scenarios
Run when:
- A command or tool is needed but not installed locally.
- You need to find which Nix package provides a specific binary.
- You need to run a one-off command with a tool from nixpkgs.
- You need multiple tools available together for a pipeline.
3. Helper Scripts
| Script | Purpose | Arguments |
|---|---|---|
scripts/nix_shell.sh |
Search/locate packages or run commands in nix shell | search <term>, locate <pattern>, or run <pkgs> -- <cmd> |
4. Subcommands
search <term> [--json] [--timeout DURATION]
Search nixpkgs for packages matching <term>.
- Default output: Clean table with package name, version, and description.
--json: Raw JSON output fromnix search.--timeout DURATION: Override the search timeout (default:5m). Format follows GNU coreutils (e.g.30s,5m,1h).- If no packages match, prints a message and exits 0.
locate <pattern> [-t TYPE] [-n LIMIT] [--timeout SECS] [-w]
Find which Nix package provides a specific file or binary. Uses nix-locate with --minimal output.
- Default type:
x(executable). Other types:r(regular file),d(directory),s(symlink). - Default limit: 100 results (use
-nto change). - Default timeout: 60 seconds (use
--timeoutto change). -w/--whole-name: Only match files whose basename matches the pattern exactly.- Output is one attribute name per line (e.g.
coreutils-prefixed.out).
run <packages...> -- <command> [args...]
Run a command with specified Nix packages available on PATH.
- Packages: Bare names are auto-prefixed with
nixpkgs#(e.g.envsubstbecomesnixpkgs#envsubst). Full flake references (containing#or:) pass through unchanged. --separator is required between packages and the command.- The process is replaced via
exec, so the exit code comes directly from the executed command.
5. Examples
Search for a package
scripts/nix_shell.sh search envsubst
Search with JSON output
scripts/nix_shell.sh search envsubst --json
Locate which package provides a binary
scripts/nix_shell.sh locate gtimeout
Locate with exact basename match and limited results
scripts/nix_shell.sh locate gtimeout -w -n 10
Locate regular files instead of executables
scripts/nix_shell.sh locate nginx.conf -t r
Run a command with a single package
scripts/nix_shell.sh run envsubst -- envsubst --help
Run with multiple packages
scripts/nix_shell.sh run envsubst jq -- sh -c 'echo "{}" | jq . && which envsubst'
Use a full flake reference
scripts/nix_shell.sh run github:NixOS/nixpkgs#hello -- hello
6. Output Format
Search (default table)
envsubst 1.4.3 Substitute environment variables in a string
Search (--json)
{
"legacyPackages.aarch64-darwin.envsubst": {
"pname": "envsubst",
"version": "1.4.3",
"description": "Substitute environment variables in a string"
}
}
Locate
One attribute name per line (minimal output):
coreutils-prefixed.out
Run
Outputs whatever the executed command produces (stdout and stderr pass through).
7. Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Invalid arguments / usage error |
| 2 | Missing prerequisite (nix not found) |
| 3 | Nix command failed (package not found, network, etc) |
| * | For run: exit code from the executed command |
8. Environment Variables
| Variable | Description |
|---|---|
NIX |
Path to nix binary (default: nix) |
9. Troubleshooting
| Problem | Possible Cause | Fix |
|---|---|---|
nix: command not found |
Nix not installed | Install Nix or Determinate Nix |
nix-locate not found |
nix-index not installed | Install nix-index package |
| Slow first run | Nixpkgs flake being evaluated | Normal on first use; cached afterward |
| Package not found | Wrong package name | Use search to find the correct name |
locate timed out |
Pattern too broad, many results | Use -w for exact match or --timeout |
missing '--' separator |
Forgot -- between pkgs and cmd |
Add -- before the command |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
eval-notebook
Execute .ipynb notebooks (Python, Kotlin, or any Jupyter kernel) without overwriting; return LLM-friendly JSON with outputs and errors. Use when you need to run or validate a Jupyter notebook.
tmux
Remote control tmux sessions for interactive CLIs (python, gdb, etc.) by sending keystrokes and scraping pane output.
slidev
Create and present web-based slidedecks for developers using Slidev with Markdown, Vue components, code highlighting, animations, and interactive features. Use when building technical presentations, conference talks, code walkthroughs, teaching materials, or developer decks. Also trigger when the user mentions Slidev, sli.dev, slide decks with code, or wants to create developer-facing presentations.
diagram-render
Render PlantUML (@startuml…@enduml) and Mermaid fenced blocks to a self-contained HTML preview; if rendering fails, the error text must be embedded in the output image. Use when the user asks to render, preview, or export diagrams.
adr-writing
Use when documenting significant architectural decisions. Creates focused ADRs explaining context, decision, and alternatives. Prevents vague documentation and implementation detail bloat. Triggers: 'create ADR', 'document decision', making technology/framework/persistence/auth choices, cross-cutting concerns.
writing-clearly-and-concisely
Use when writing documentation, commit messages, error text, explanations, reports, or summaries. Applies Strunk's principles for clear, vigorous prose. Triggers: writing human-readable content, verbose text, unclear explanations.
Didn't find tool you were looking for?