LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix-shell

creates temporary development environments

TLDR

Enter shell with package
$ nix-shell -p [hello]
copy
Enter shell from default.nix
$ nix-shell
copy
Enter shell from file
$ nix-shell [shell.nix]
copy
Run command in shell
$ nix-shell -p [jq] --run "[jq --version]"
copy
Pure shell
$ nix-shell --pure -p [python3]
copy
Multiple packages
$ nix-shell -p [python3] [nodejs] [git]
copy

SYNOPSIS

nix-shell [options] [path]

DESCRIPTION

nix-shell creates temporary development environments. Provides packages without installing.The tool sets up shell with dependencies. Exits cleanly without system changes.

PARAMETERS

PATH

Nix expression file.
-p PACKAGES
Packages to include.
--run CMD
Command to execute.
--pure
Clear environment.
-A ATTR
Use specific attribute.
-I PATH
Add path to Nix expression search path (e.g., `-I nixpkgs=/path/to/nixpkgs`).
--command CMD
Run a command then stay in the shell (unlike `--run`, which exits after).
--keep VAR
Keep an environment variable when using `--pure`.
--packages
Long form of `-p`.
-i INTERPRETER
Use as a shebang interpreter (see `#!nix-shell` scripts).
--help
Display help information.

CAVEATS

Legacy command. Consider nix develop. Per-invocation environment.

HISTORY

nix-shell is a core Nix command for creating temporary development shells.

SEE ALSO

nix-develop(1), nix(1), direnv(1)

Copied to clipboard
Kai