Forrest logo
tool overview
On this page you find all important commands for the CLI tool nix-shell. If the command you are looking for is missing please ask our AI.

nix-shell

nix-shell is a command-line tool used in the Nix package manager ecosystem, which provides a reproducible and declarative approach to package management. It allows for the creation of isolated development environments, making it easier to manage dependencies and ensure consistency across different projects.

Using nix-shell, developers can enter an interactive shell within a specific environment defined by a Nix expression file. This file describes the package dependencies, build instructions, and other related settings necessary for the project.

nix-shell creates an isolated environment by pulling in the required dependencies and setting up the necessary environment variables, paths, and configurations. It ensures that the environment is self-contained and independent of the host system.

The tool gives developers access to all the packages and utilities defined within the Nix expression file, allowing them to seamlessly work with the required tools without polluting their global system.

Developers can use nix-shell to enable specific versions of programming languages, compilers, libraries, or any other required dependencies, ensuring that everyone working on the project uses the same environment.

It can be used to set up development environments for various programming languages, like Python, JavaScript, Rust, or Haskell, among others.

nix-shell simplifies the process of reproducing a project's environment across different machines, making it ideal for collaborative development, continuous integration, and deployment workflows.

The tool can also be combined with other Nix tools, like nix-build or nix-env, enabling powerful workflows for building projects, managing package installations, and creating reproducible deployments.

Overall, nix-shell provides developers with a convenient and controlled environment for working on projects, eliminating dependency conflicts and reducing the time spent on environment setup and configuration.

List of commands for nix-shell:

  • nix-classic:tldr:6bedc nix-classic: Start a shell with the specified packages available.
    $ nix-shell -p ${pkg1 pkg2 pkg3---}
    try on your machine
    explain this command
  • nix-shell:tldr:0fb2c nix-shell: Start with nix expression in `shell.nix` or `default.nix` in the current directory.
    $ nix-shell
    try on your machine
    explain this command
  • nix-shell:tldr:42f88 nix-shell: Start with packages loaded from specific nixpkgs revision.
    $ nix-shell --packages ${package_name_1 package_name_2 ---} -I nixpkgs=${https:--github-com-NixOS-nixpkgs-archive-nixpkgs_revision-tar-gz}
    try on your machine
    explain this command
  • nix-shell:tldr:7338b nix-shell: Start with expression in `default.nix` in the current directory.
    $ nix-shell ${default-nix}
    try on your machine
    explain this command
  • nix-shell:tldr:b6cd7 nix-shell: Evaluate rest of file in specific interpreter, for use in `#!-scripts` (see ).
    $ nix-shell -i ${interpreter} --packages ${package_name_1 package_name_2 ---}
    try on your machine
    explain this command
  • nix-shell:tldr:c420e nix-shell: Run shell command in non-interactive shell and exit.
    $ nix-shell --run "${command} ${arg1 arg2 ---}"
    try on your machine
    explain this command
  • nix-shell:tldr:d5180 nix-shell: Start with packages loaded from nixpkgs.
    $ nix-shell --packages ${package_name_1 package_name_2 ---}
    try on your machine
    explain this command
tool overview