YOUR JOURNEY
04 / 18
01NIX FUNDAMENTALS 5 MIN READ
LESSON 04 / YOUR FIRST NIX SHELL

Try a tool.
Leave no setup.

Borrow a package for one shell session.

Let’s make the mental model tangible. Open a shell with a package, use it, then return to your original environment.

Explore the lesson
~$ Build your understanding, one idea at a time.
THE NIX MODEL01 / 03
Drag to rotate

Nix obtains the requested packages in its store.

Packages cached in the store
04.1FIRST, NIX

Keep your current Linux distribution.

If Nix is not installed, follow the official installation guide linked below for your platform, then open a new terminal and check nix --version. These examples run on your machine; this website does not execute shell commands.

The classic nix-shell command works without enabling flakes. It looks up packages through your configured Nixpkgs source, often a channel. If <nixpkgs> cannot be found, finish your installer’s channel setup first.

terminal
nix --version
nix-shell -p hello git
 
# Inside the new shell:
hello
git --version
exit
Next section: A new shell, not a container.
04.2WHAT CHANGED?

A new shell, not a container.

Within the shell, the requested programs are available on PATH. Exiting returns to the parent environment. Downloaded files can remain in /nix/store until garbage collection removes them.

This shell is not a security sandbox. Programs can still access your normal files and network. Also, an unpinned Nixpkgs source can change over time: “the same command” alone does not guarantee the same package versions.

run once
nix-shell -p hello --run hello
# Expected program output: Hello, world!
TAKE THIS WITH YOU

A Nix shell changes which tools are available; it does not isolate your files or erase cached packages on exit.

UP NEXT

Read the Nix language

You only need a few building blocks to start reading Nix.

Next lesson