Nix Shell

You can use Nix packages without installing them globally on your machine. This is a good way to bring in the tools you need for individual projects.

$ nix-shell -p hello

[nix-shell:nix-workshop]$ hello
Hello, world!

Using Multiple Packages

$ nix-shell -p nodejs ghc cabal-install

[nix-shell:nix-workshop]$ which node

[nix-shell:nix-workshop]$ which ghc

[nix-shell:nix-workshop]$ which cabal

Using shell.nix

It is common practice for Nix-using projects to provide a shell.nix file that specifies the shell environment. The nix-shell command reads this file, allowing us to create reproducible shell environments without using -p. These environments can provide access to any tool written in any language, without polluting the global environment. We will cover the use of shell.nix in a later chapter.