Warning: This program is experimental and its interface is subject to change.
Name
nix shell - run a shell in which the specified packages are available
Synopsis
nix shell [option…] installables…
Examples
- •
-
Start a shell providing
youtube-dlfrom thenixpkgsflake:
# nix shell nixpkgs#youtube-dl # youtube-dl --version 2020.11.01.1
- •
-
Start a shell providing GNU Hello from NixOS 20.03:
# nix shell nixpkgs/nixos-20.03#hello
- •
-
Run GNU Hello:
# nix shell nixpkgs#hello -c hello --greeting 'Hi everybody!' Hi everybody!
- •
-
Run GNU Hello in a chroot store:
# nix shell --store ~/my-nix nixpkgs#hello -c hello
- •
-
Start a shell providing GNU Hello in a chroot store:
# nix shell --store ~/my-nix nixpkgs#hello nixpkgs#bashInteractive -c bash
-
Note that it’s necessary to specify
bashexplicitly because your default shell (e.g./bin/bash) generally will not exist in the chroot.
Description
nix shell runs a command in an environment in which the $PATH variable provides the specified installables. If no command is specified, it starts the default shell of your user account specified by $SHELL.
Options
- •
-
--command/-ccommand args
Command and arguments to be executed, defaulting to$SHELL
- •
-
--ignore-environment/-i
Clear the entire environment (except those specified with--keep).
- •
-
--keep/-kname
Keep the environment variable name.
- •
-
--unset/-uname
Unset the environment variable name.
Common evaluation options:
- •
-
--argname expr
Pass the value expr as the argument name to Nix functions.
- •
-
--argstrname string
Pass the string string as the argument name to Nix functions.
- •
-
--eval-storestore-url
The Nix store to use for evaluations.
- •
-
--impure
Allow access to mutable paths and repositories.
- •
-
--include/-Ipath
Add path to the list of locations used to look up<...>file names.
- •
-
--override-flakeoriginal-ref resolved-ref
Override the flake registries, redirecting original-ref to resolved-ref.
Common flake-related options:
- •
-
--commit-lock-file
Commit changes to the flake’s lock file.
- •
-
--inputs-fromflake-url
Use the inputs of the specified flake as registry entries.
- •
-
--no-registries
Don’t allow lookups in the flake registries. This option is deprecated; use--no-use-registries.
- •
-
--no-update-lock-file
Do not allow any updates to the flake’s lock file.
- •
-
--no-write-lock-file
Do not write the flake’s newly generated lock file.
- •
-
--override-inputinput-path flake-url
Override a specific flake input (e.g.dwarffs/nixpkgs). This implies--no-write-lock-file.
- •
-
--recreate-lock-file
Recreate the flake’s lock file from scratch.
- •
-
--update-inputinput-path
Update a specific flake input (ignoring its previous entry in the lock file).
Options that change the interpretation of installables:
- •
-
--derivation
Operate on the store derivation rather than its outputs.
- •
-
--exprexpr
Interpret installables as attribute paths relative to the Nix expression expr.
- •
-
--file/-ffile
Interpret installables as attribute paths relative to the Nix expression stored in file. If file is the character -, then a Nix expression will be read from standard input.