aboutsummaryrefslogtreecommitdiff
path: root/src/nix/shell.md
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-12-08 17:16:23 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-12-21 13:32:27 +0100
commit09660b855778531be14968b720308d092af4dd2e (patch)
treef79e61c9b080ac0b49028ef771d76da9fe9f0d0f /src/nix/shell.md
parentae7351dbeed3d03087b6b56d23b4b3942de1507d (diff)
Add 'nix run' and 'nix shell' manpages
Diffstat (limited to 'src/nix/shell.md')
-rw-r--r--src/nix/shell.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nix/shell.md b/src/nix/shell.md
new file mode 100644
index 000000000..2a379e03f
--- /dev/null
+++ b/src/nix/shell.md
@@ -0,0 +1,48 @@
+R""(
+
+# 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 -c hello --greeting 'Hi everybody!'
+ Hi everybody!
+ ```
+
+* Run GNU Hello in a chroot store:
+
+ ```console
+ # nix shell --store ~/my-nix nixpkgs#hello -c hello
+ ```
+
+* Start a shell providing GNU Hello in a chroot store:
+
+ ```console
+ # 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 not command is
+specified, it starts the default shell of your user account.
+
+)""