用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Misterio77/Foundry --skill nix-shell命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | nix-shell |
| description | Use `nix shell` for ephemeral environments and one-off commands without installing packages globally. |
The canonical form for running a single command in a temporary nix environment:
nix shell nixpkgs#<package> -c <command> [args...]
The -c flag tells nix shell to exec the following arguments as a command.
Everything after -c is passed straight to the shell, so quoting works naturally.
DO NOT, under any circumstances, double-quote "<command> [args...]" together. This will cause bash to treat the entire thing as the executable name:
nix shell nixpkgs#python3 -c "python3 foo.py arg1 arg2"nix shell nixpkgs#python3 -c python3 foo.py arg1 arg2nix shell nixpkgs#jq -c jq '.foo' file.json
nix shell nixpkgs#yq -c yq eval '.foo.bar' file.yml
nix shell nixpkgs#httpie -c https httpbin.org/json
For ephemeral environments with multiple tools (where the "command" is sh):
nix shell nixpkgs#jq nixpkgs#yq nixpkgs#curl -c sh
This drops you into an interactive shell with all three available. Exit with exit or ^D.
nix run insteadnix run is more concise when you just need to run a tool's default binary and
don't need to control the invoked command name:
nix run nixpkgs#jq -- -r '.name' file.json
Use nix run when:
-- is passed to the binary)Use nix shell when:
nixpkgs#nodePackages.prettier)nix shell nixpkgs#python3Packages.<name> doesn't work — the Python binary
won't see the package. Instead, use nix eval --apply to get the
python3.withPackages derivation path, then ask nix shell for its out output:
nix shell "$(
nix eval nixpkgs#python3 --raw --apply \
'py: (py.withPackages (p: [ p.requests ])).drvPath'
)^out" -c python3 -c '
import requests
print(requests.get("https://httpbin.org/json").json()["slideshow"]["title"])
'
For multiple packages/tools, add them to the same shell:
nix shell "$(
nix eval nixpkgs#python3 --raw --apply \
'py: (py.withPackages (p: [ p.playwright ])).drvPath'
)^out" \
nixpkgs#chromium \
-c python3 -c '
from playwright.sync_api import sync_playwright
print("works")
'
Important details:
.drvPath with ^out; plain .outPath may be unrealized.^out outside the command substitution, as part of the installable path.nix shell, use
nix build --no-link --print-out-paths to realize the output first.nix search nixpkgs <query>
If a command fails with "command not found", wrap it with nix shell instead of installing the package globally:
# instead of: apt install jq (never)
# instead of: nix profile install nixpkgs#jq (avoid for one-offs)
nix shell nixpkgs#jq -c jq '.foo' data.json