lix/src/nix/shell.md
Qyriad 194ba8a02f docs: guide to installables docs in installable commands' docs
The installables syntax is not documented in any of the man pages or
docbook pages for any of those individual commands. And while these
commands really should at least peripherally individually document how
installables work, in the meantime we can at least direct people to the
right place.

This commit also clarifies the unexpected fact that `nix profile remove`
and `nix profile upgrade` do *not* take installables.

Change-Id: I3b1453cb197a613bbab639c66a466365c3592c6d
2024-04-29 08:06:05 -06:00

1.4 KiB

R""(

Note: this command's interface is based heavily around installables, which you may want to read about first (nix --help).

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 --command hello --greeting 'Hi everybody!'
    Hi everybody!
    
  • Run multiple commands in a shell environment:

    # nix shell nixpkgs#gnumake --command sh -c "cd src && make"
    
  • Run GNU Hello in a chroot store:

    # nix shell --store ~/my-nix nixpkgs#hello --command hello
    
  • Start a shell providing GNU Hello in a chroot store:

    # nix shell --store ~/my-nix nixpkgs#hello nixpkgs#bashInteractive --command 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.

)""