nix-shell.3
Start an interactive shell based on a Nix expression
TLDR
SYNOPSIS
nix-shell [options] [path]
DESCRIPTION
nix-shell starts an interactive shell in which the environment is set up based on a Nix expression. It provides all build dependencies of the specified derivation without actually building it, making it ideal for development environments.
When used with --packages/-p, it creates ad-hoc environments with specific packages available. When used with --pure, the host environment is cleared to closely match a real Nix build environment.
nix-shell can also be used as a script interpreter via shebang lines (`#!/usr/bin/env nix-shell`) to create reproducible scripts with declared dependencies.
PARAMETERS
PATH
Nix expression file (default: shell.nix or default.nix).-p, --packages packages...
Set up an environment with the specified packages from Nixpkgs.--pure
Clear the environment before starting the shell, retaining only HOME, USER, and DISPLAY.--run cmd
Run a command in a non-interactive shell, then exit.--command cmd
Run a command in an interactive shell, then exit.-A, --attr attrPath
Select an attribute from the Nix expression.--keep name
Keep an environment variable when using --pure.--exclude regexp
Do not build dependencies whose store path matches the regexp.-i interpreter
Specify the interpreter for nix-shell shebang scripts.-v
Verbose output.
CAVEATS
Without --pure, the host environment leaks into the shell, which may cause builds to succeed locally but fail in a clean Nix build. The --packages flag uses Nixpkgs attribute names, not package names.

