AGENT SKILL

pynix

Run Nix through the pynix CLI instead of the nix CLI -- eval, build, develop, print-dev-env, path-info, log, why-depends, copy, store, search, flake, config, registry. Load before any Nix command; fall back to nix only for what pynix lacks.

License 许可
Apache-2.0
所属仓库
nixidae/nixidae
最近更新
2026-11-15
Stars
★ 1
Forks
0

01 前言 Front Matter

name
pynix
description
Run Nix through the pynix CLI instead of the nix CLI -- eval, build, develop, print-dev-env, path-info, log, why-depends, copy, store, search, flake, config, registry. Load before any Nix command; fall back to nix only for what pynix lacks.

03 SKILL.md 正文

pynix

pynix is nanopynix's Nix CLI: libnix in-process, results as JSON on stdout. Use it in place of nix for every command it has. Agent use is the dogfood: a gap or a bug found here is a pynix issue, not a reason to drop it quietly.

Mapping

nix pynix
nix eval --file . a.b pynix eval --file . --attr a.b or --file '.#a.b'
nix eval --expr E pynix eval --expr E (pure unless --impure), or E on stdin (impure, below)
nix eval --json ... pynix eval --json ...: nix's compact line; default is indented JSON
nix build --file . a b pynix build --file . --attr a --attr b
nix build --expr E a pynix build --expr E --attr a (pure unless --impure)
nix build --no-link --print-out-paths ... same flags: one path per line; --no-link changes nothing
nix build --keep-going / -k same
nix build .#a pynix build --flake .#a
nix run, nix shell pynix run, pynix shell (= pynix env shell)
nix develop --file . a -c CMD pynix develop --file . --attr a -- CMD
nix print-dev-env pynix print-dev-env [--json]
nix path-info P pynix path-info P (one path)
nix log P, nix why-depends A B [--precise] same verb
nix copy --to S P pynix copy --to S P, or --file/--flake instead of P
nix store gc/ls/cat/diff-closures/verify/... pynix store <same>
nix derivation show --file . a pynix derivation show --file . --attr a (a target, not a .drv path; stdout is nix's document, .derivations["<base>.drv"])
nix flake show/metadata, nix config show, nix registry same verbs
nix search, option search pynix search --file '<nixpkgs>' [--options/--packages] QUERY [--json-output]; --file/--flake required

Differences that bite:

  • No positional attribute: pynix build --file . foo is a usage error. Use --attr foo or --file '.#foo'. build repeats --attr; other commands take one target.
  • --file takes a path, <name> lookup path, URL or flake ref, each with an optional #attr. A bare word (nixpkgs) tries NIX_PATH first, then the registry; write local paths with ./.
  • build writes no result link unless --out-link. Its stdout is {"outputs": {"out": "/nix/store/..."}, ...}; --print-out-paths prints nix's lines instead.
  • eval prints indented JSON; --json prints nix's compact line; --raw prints the string.
  • build --dry-run belongs to --update-fod; alone it builds nothing and prints nothing.
  • Store selection is --store URI, plus --eval-store on build and develop.

Output

stdout holds only the result. stderr holds what nix would print: warnings, errors, building '...'..., and build logs with --print-build-logs. A build that changes nothing prints nothing there. Do not discard stderr; it is where the error is. --verbosity talkative adds pynix's own progress events.

A stderr line that is noise, not news, is a pynix bug: file it.

Nix programs on stdin

--file - reads the expression from stdin in every command that takes --file, so a heredoc carries a Nix program with no temporary file:

pynix build --file - <<'EOF'
with import <nixpkgs> { }; runCommand "x" { } "echo hi > $out"
EOF
  • Treated as a file: a function is called with its defaults, and --attr selects. A fragment needs =: --file=-#a.b, because argparse reads a separate -#a.b as an option.
  • ./x names from the working directory, as with nix --file -.
  • pynix eval with neither --expr nor --file also reads stdin.
  • Not in pynix repl, which reads its commands from stdin.

pynix-only

  • build --nom: nix-output-monitor style progress on stderr.
  • build --update-fod [--dry-run]: rewrites stale fixed-output hash literals.
  • build --namespaced [--overlay-dir D] [--copy-back] [--sandbox-path P]: a build in a private user namespace over an overlay of the host store. The host store is unchanged unless --copy-back. Linux only.
  • build --copy URI: copy the output closure to another store after the build.
  • search with no query and a terminal opens a TUI; pass a query or --no-tui.

Fall back to nix

Use nix only for what pynix lacks, and say so in the reply: a subcommand missing from pynix --help, or a flag its --help lacks.

Before falling back, or after a pynix failure that nix does not share, search gh issue list -R nixidae/nixidae --search "pynix ...". If no issue covers it, file one in nixidae/nixidae with label source: nanopynix: the command, the nix command that works, the stderr log.

Configuration

Defaults come from, first wins: the flag, PYNIX_<OPTION> / PYNIX_NIX_<SETTING>, $XDG_CONFIG_HOME/pynix/config.toml ([defaults] for pynix options, [nix] for Nix settings), the built-in default.

04 同仓库更多 Skills