@sergioia_dev/pi-nix0.1.2
Pi extension adding a /nix command for nix develop, nix-shell, and one-off nix commands
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-nix
A Pi extension that adds a /nix command for entering Nix development shells and running Nix commands.
Install
From this directory:
pi install ./
Or load it for one session:
pi -e .
After npm publishing:
pi install npm:@sergioia_dev/pi-nix
Bundled skill
nix-usage ships with this package. It explains when to use nix develop, nix shell, legacy nix-shell, nix run, nix build, and other Nix commands, and how each maps to /nix.
Load it explicitly with /skill:nix-usage. Pi may also load it automatically for Nix command questions.
Usage
/nix develop <args> [-- <command>]
/nix shell <args> [-- <command>]
/nix build [flags] [installables]
/nix <subcommand> <args>
/nix off
Enter a devshell
/nix develop
/nix develop .#backend
/nix develop .#backend -- cargo test
/nix develop defaults to .. The environment is captured from nix develop <args> --command bash -c ... and applied to the agent's bash tool and user ! commands.
Enter a nix shell
/nix shell
/nix shell -p hello
/nix shell -p hello -- hello
/nix shell nixpkgs#hello
/nix shell nixpkgs#hello -- hello
/nix shell uses legacy nix-shell for -p and other nix-shell arguments, and modern nix shell when an argument contains a flake installable such as nixpkgs#hello. The first run may download packages.
While an environment is captured, a live ❄ indicator shows a spinner, elapsed
time, and the latest Nix download or build line. It clears when activation
finishes; first runs may download packages.
Build with live progress
/nix build uses the bundled build engine from
pi-nix-build v0.2.2: live progress,
per-derivation logs, failure and hash-mismatch diagnostics, and a fullscreen
detail view. The engine is vendored, so pi-nix-build must not be installed
alongside this package (it would register the same tools twice).
/nix build .#hello
/nix build --dry-run .#hello
/nix build --out-link result .#hello
/nix build --background .#hello
/nix build -f default.nix -A hello
/nix build -E 'import ./default.nix'
Supported flags:
| Flag | Meaning |
|---|---|
-f, --file |
Nix file (legacy nix-build) |
-E, --expr |
Nix expression (legacy nix-build) |
-A, --attr |
Attribute path; repeatable |
-o, --out-link |
Result symlink |
--dry-run |
Plan the build without realising it |
--background |
Start a job and return its id (nix_jobs can wait for it) |
-- |
Pass the remaining arguments through |
Unlisted Nix flags must follow --. --file/--expr cannot be combined
with flake installables, and --attr requires one of them.
The engine also registers the model-facing nix_build, nix_check, nix_eval,
nix_log, and nix_jobs tools. Raw nix build calls from the agent's bash tool
are redirected to nix_build.
Shortcuts, while a build is running:
Ctrl+Shift+B— collapse or expand build progress.Ctrl+Shift+M— show the expanded or latest build fullscreen.
Background jobs are managed with the nix_jobs tool.
Run a one-off Nix command
/nix run .#app -- --flag
/nix flake show
Any subcommand other than develop, shell, build, and off is passed to nix as a one-off command:
nix <subcommand> <args>
One-off commands run with Pi's host environment. They do not activate, deactivate, or modify the current shell. Use the agent's bash tool or ! if you want a one-off command inside the active devshell.
Deactivate
/nix off
/nix develop off is treated as a nix develop argument named off, not as deactivation.
Behavior
- The active environment applies to the built-in
bashtool and user!commands only.read,grep,find, andlskeep Pi's host environment. - Pi is not restarted and
process.envis not modified. A manual/reload, session switch, or exit clears the active shell; run/nix developor/nix shellagain. - The extension captures exported environment values, including exported bash functions (
BASH_FUNC_*). Shell aliases and unexported shell variables are not captured. - Activation arguments are passed literally; no variable or
~expansion is performed. -c,--command, and (fornix-shell)--runare reserved because the extension uses them to capture the environment. Use the-- <command>form instead.- Capturing the environment times out after 15 minutes. Tail commands and one-off commands use a 30-minute timeout when the UI cannot show a terminal.
- A failed activation leaves the previously active environment untouched.
Development
npm install
npm run check
npm pack --dry-run
pi -e .
npm run check runs TypeScript type checking and the unit tests.
License
MIT. The build engine under vendor/pi-nix-build/ is MIT-licensed
pi-nix-build v0.2.2; see
vendor/pi-nix-build/LICENSE.