Forrest logo
back to the nix-shell tool

nix-shell:tldr:b6cd7

nix-shell: Evaluate rest of file in specific interpreter, for use in `#!-scripts` (see <https://nixos.org/manual/nix/stable/#use-as-a-interpreter>).
$ nix-shell -i ${interpreter} --packages ${package_name_1 package_name_2 ---}
try on your machine

The command nix-shell -i ${interpreter} --packages ${package_name_1 package_name_2 ---} is used in the Nix package manager to start an interactive shell environment with specific packages installed.

Here is a breakdown of the command:

  • nix-shell: This command starts an interactive shell environment with the specified packages available.

  • -i ${interpreter}: This option specifies the interpreter to use within the shell environment. You can replace ${interpreter} with the desired interpreter, such as python3 or bash, to have it available in the shell.

  • --packages ${package_name_1 package_name_2 ---}: This option specifies the packages that should be installed and made available within the shell environment. You can replace ${package_name_1 package_name_2 ---} with the specific package names you want to install. Multiple package names can be specified, separated by spaces.

By running this command, you will enter an interactive shell environment with the specified packages installed and ready to use. It allows you to work in a controlled environment with specific dependencies, making it easier to manage and reproduce your development or build environment.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nix-shell tool