https://nixos.org/download/#nix-install-linux
Let’s run our first programs with Nix. We will be using nix-shell
for this.
nix-shell -p cowsay lolcat
Now that we’re inside the shell, we can use them
cowsay Hello, Nix! | lolcat
_____________
< Hello, Nix! >
-------------
\\ ^__^
\\ (oo)\\_______
(__)\\ )\\/\\
||----w |
|| ||
We can simply pipe our echo
to lolcat
To run a program once, we can
nix-shell -p hello --run hello
Hello, world!
Sometimes it is necessary to ensure that the nix shell does not contain any packages we have in our own environment. We can pass a --pure
flag to ensure only dependencies in shell.nix
is considered.
nix-shell --pure
<aside> 💡
We would like to have a fully reproducible example would give exactly the same results no matter when or where you run the command. The environment provided would be identical each time.