Nix 101 Course / Section 1: Getting started: install Nix and score your first wins
Premium

1.4 Your first Nix commands: nix run and nix shell

Lesson 4 of 68 · 5:27

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

You just installed Nix, now what? This lesson shows the two commands that make Nix useful within minutes: nix run to launch any program from nixpkgs without installing it, and nix shell to open a temporary shell where the tool simply exists. Along the way you learn what nixpkgs#hello actually means, and how to run an older version of a package on purpose.

In this video

  • Running a program straight from nixpkgs with nix run: nothing installed, nothing left behind
  • What the # in nixpkgs#hello really is, and where the name nixpkgs comes from (hint: there is a registry)
  • The small -- detail that decides whether an argument goes to Nix or to the program, a classic beginner trap
  • Getting an old package version by pointing at a different nixpkgs branch: ripgrep 13 and 15 on the same machine, no conflict
  • Temporary shells with nix shell: what happens to your PATH, how shells nest, a bash trick for several packages at once, and the shorter classic nix-shell -p the instructor uses daily

After this lesson

You can try out any program from nixpkgs on demand, in the version you want, without installing anything or cleaning up afterwards.