Linux command
nix3-shell 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Enter a shell with a package available
nix shell nixpkgs#[hello]
Enter a shell with multiple packages
nix shell nixpkgs#[git] nixpkgs#[curl]
Run a single command with a package and exit
nix shell nixpkgs#[jq] --command jq --version
Enter a shell with a package from a specific flake
nix shell github:[owner/repo]#[package]
Enter a shell with a package
nix shell github:NixOS/nixpkgs/[nixos-24.05]#[hello]
说明
nix shell starts a shell environment with the specified packages available in `$PATH`. It is the flake-based replacement for `nix-shell -p` and does not require a shell.nix or default.nix file. Packages are specified as flake references (e.g., `nixpkgs#jq`). The packages are built or fetched as needed and made available only in the spawned shell session. Nothing is permanently installed.
参数
- --command, -c _CMD_ _ARGS_
- Run a command in the shell environment instead of starting an interactive shell.
- --ignore-environment, -i
- Clear the entire environment (except those specified with --keep).
- --keep _NAME_
- Keep the specified environment variable when using --ignore-environment.
- --keep-going
- Continue building other derivations if one fails.
- --impure
- Allow access to mutable paths and environment variables.
- --override-input _INPUT_ _FLAKEREF_
- Override a specific flake input. Implies --no-write-lock-file.
- --help
- Display help information.
FAQ
What is the nix3-shell command used for?
nix shell starts a shell environment with the specified packages available in `$PATH`. It is the flake-based replacement for `nix-shell -p` and does not require a shell.nix or default.nix file. Packages are specified as flake references (e.g., `nixpkgs#jq`). The packages are built or fetched as needed and made available only in the spawned shell session. Nothing is permanently installed.
How do I run a basic nix3-shell example?
Run `nix shell nixpkgs#[hello]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --command, -c _CMD_ _ARGS_ do in nix3-shell?
Run a command in the shell environment instead of starting an interactive shell.