1.4 Your first Nix commands: nix run and nix shell
Lesson 4 of 68 · 5:27
Up next in 5s…
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
#innixpkgs#helloreally is, and where the namenixpkgscomes 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:
ripgrep13 and 15 on the same machine, no conflict - Temporary shells with
nix shell: what happens to yourPATH, how shells nest, a bash trick for several packages at once, and the shorter classicnix-shell -pthe 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.