blob: 598a39854376b6cc9874572c77d804884cc25a0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
R""(
**Note:** this command's interface is based heavily around [*installables*](./nix.md#installables), which you may want to read about first (`nix --help`).
# Examples
* Start a shell providing `youtube-dl` from the `nixpkgs` flake:
```console
# nix shell nixpkgs#youtube-dl
# youtube-dl --version
2020.11.01.1
```
* Start a shell providing GNU Hello from NixOS 20.03:
```console
# nix shell nixpkgs/nixos-20.03#hello
```
* Run GNU Hello:
```console
# nix shell nixpkgs#hello --command hello --greeting 'Hi everybody!'
Hi everybody!
```
* Run multiple commands in a shell environment:
```console
# nix shell nixpkgs#gnumake --command sh -c "cd src && make"
```
* Run GNU Hello in a chroot store:
```console
# nix shell --store ~/my-nix nixpkgs#hello --command hello
```
* Start a shell providing GNU Hello in a chroot store:
```console
# 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*](./nix.md#installable). If no command is specified, it starts the
default shell of your user account specified by `$SHELL`.
)""
|