lix/src/nix/shell.md
Valentin Gagarin 2af9fd20c6 clarify definition of "installable"
the term was hard to discover, as its definition and explanation were in
a very long document lacking an overview section.
search did not help because it occurs so often.

- clarify wording in the definition
- add an overview of installable types
- add "installable" to glossary
- link to definition from occurrences of the term
- be more precise about where store derivation outputs are processed
- installable Nix expressions must evaluate to a derivation

Co-authored-by: Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>
2023-03-05 01:46:17 +01:00

1.2 KiB

R""(

Examples

  • Start a shell providing youtube-dl from the nixpkgs flake:

    # 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 multiple commands in a shell environment:

    # nix shell nixpkgs#gnumake -c sh -c "cd src && make"
    
  • 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 bash explicitly 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.

)""